interest: minor cleanups
Refs: #4567
Change-Id: I4e2428cc7f64cc9fceaae5c8f928fe4fc52e4cc7
diff --git a/ndn-cxx/interest.cpp b/ndn-cxx/interest.cpp
index 42917e2..68a8ced 100644
--- a/ndn-cxx/interest.cpp
+++ b/ndn-cxx/interest.cpp
@@ -95,13 +95,6 @@
#endif // NDN_CXX_HAVE_TESTS
}
- return encode03(encoder);
-}
-
-template<encoding::Tag TAG>
-size_t
-Interest::encode03(EncodingImpl<TAG>& encoder) const
-{
// Encode as NDN Packet Format v0.3
// Interest = INTEREST-TYPE TLV-LENGTH
// Name
@@ -195,18 +188,9 @@
if (wire.type() != tlv::Interest) {
NDN_THROW(Error("Interest", wire.type()));
}
-
m_wire = wire;
m_wire.parse();
- decode03();
- getNonce(); // force generation of nonce
- m_isCanBePrefixSet = true; // don't trigger warning from decoded packet
-}
-
-void
-Interest::decode03()
-{
// Interest = INTEREST-TYPE TLV-LENGTH
// Name
// [CanBePrefix]
@@ -233,6 +217,7 @@
}
m_name = std::move(tempName);
+ m_isCanBePrefixSet = true; // don't trigger warning from decoded packet
m_canBePrefix = m_mustBeFresh = false;
m_forwardingHint = {};
m_nonce.reset();
@@ -332,6 +317,8 @@
if (s_autoCheckParametersDigest && !isParametersDigestValid()) {
NDN_THROW(Error("ParametersSha256DigestComponent does not match the SHA-256 of Interest parameters"));
}
+
+ getNonce(); // force generation of nonce
}
std::string
diff --git a/ndn-cxx/interest.hpp b/ndn-cxx/interest.hpp
index 9a612b3..c386ce8 100644
--- a/ndn-cxx/interest.hpp
+++ b/ndn-cxx/interest.hpp
@@ -66,7 +66,7 @@
explicit
Interest(const Block& wire);
- /** @brief Prepend wire encoding to @p encoder.
+ /** @brief Prepend wire encoding to @p encoder according to NDN Packet Format v0.3.
*/
template<encoding::Tag TAG>
size_t
@@ -355,18 +355,6 @@
isParametersDigestValid() const;
private:
- /** @brief Prepend wire encoding to @p encoder in NDN Packet Format v0.3.
- */
- template<encoding::Tag TAG>
- size_t
- encode03(EncodingImpl<TAG>& encoder) const;
-
- /** @brief Decode @c m_wire as NDN Packet Format v0.3.
- * @throw tlv::Error decoding error.
- */
- void
- decode03();
-
void
setApplicationParametersInternal(Block parameters);
@@ -403,13 +391,13 @@
static bool s_autoCheckParametersDigest;
Name m_name;
- mutable bool m_isCanBePrefixSet = false;
- bool m_canBePrefix = true;
- bool m_mustBeFresh = false;
DelegationList m_forwardingHint;
mutable optional<uint32_t> m_nonce;
time::milliseconds m_interestLifetime;
optional<uint8_t> m_hopLimit;
+ mutable bool m_isCanBePrefixSet = false;
+ bool m_canBePrefix = true;
+ bool m_mustBeFresh = false;
// Stores the "Interest parameters", i.e., all maybe-unrecognized non-critical TLV
// elements that appear at the end of the Interest, starting from ApplicationParameters.