interest: setNonce resets wire buffer
Prior to this commit, Interest::setNonce overwrote part of the wire
buffer, which could lead to unexpected behavior: when two Interest
instances are sharing the same wire buffer, setting the Nonce on one
instance affects the other instance.
refs #4168
Change-Id: Ia90ed54d91845575504ca53071ea356e3854eba5
diff --git a/src/interest.hpp b/src/interest.hpp
index a00bbc0..7a45bc8 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -155,20 +155,17 @@
bool
hasNonce() const
{
- return m_nonce.hasWire();
+ return static_cast<bool>(m_nonce);
}
- /** @brief Get Interest's nonce
+ /** @brief Get nonce
*
* If nonce was not set before this call, it will be automatically assigned to a random value
*/
uint32_t
getNonce() const;
- /** @brief Set Interest's nonce
- *
- * If wire format already exists, this call simply replaces nonce in the
- * existing wire format, without resetting and recreating it.
+ /** @brief Set nonce
*/
Interest&
setNonce(uint32_t nonce);
@@ -406,7 +403,7 @@
private:
Name m_name;
Selectors m_selectors;
- mutable Block m_nonce;
+ mutable optional<uint32_t> m_nonce;
time::milliseconds m_interestLifetime;
DelegationList m_forwardingHint;