Transition to v0.3 format
Set CanBePrefix on interests
Remove remaining exclude filter logic
refs: #4691, #4684
Change-Id: I6d1b23ba9973f5b54ba49e5122b18ac0d9f88720
diff --git a/common.hpp b/common.hpp
index d59fa9c..59e6828 100644
--- a/common.hpp
+++ b/common.hpp
@@ -78,7 +78,6 @@
using ndn::Block;
using ndn::ConstBufferPtr;
using ndn::Data;
-using ndn::Exclude;
using ndn::Interest;
using ndn::Name;
using ndn::security::v2::ValidationError;
diff --git a/src/logic.cpp b/src/logic.cpp
index ab0b794..35480ee 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -360,8 +360,7 @@
else if (name.size() >= 2 && RECOVERY_COMPONENT == name.get(-2)) {
processRecoveryInterest(interest);
}
- // Do not process exclude interests, they should be answered by CS
- else if (interest.getExclude().empty()) {
+ else {
processSyncInterest(interest);
}
@@ -379,22 +378,12 @@
Logic::onSyncData(const Interest& interest, const Data& data)
{
_LOG_DEBUG_ID(">> Logic::onSyncData");
- // if (static_cast<bool>(m_validator))
- // m_validator->validate(data,
- // bind(&Logic::onSyncDataValidated, this, _1),
- // bind(&Logic::onSyncDataValidationFailed, this, _1));
- // else
- // onSyncDataValidated(data);
-
- if (interest.getExclude().empty()) {
- _LOG_DEBUG_ID("First data");
- onSyncDataValidated(data);
- }
- else {
- _LOG_DEBUG_ID("Data obtained using exclude filter");
- onSyncDataValidated(data, false);
- }
- // sendExcludeInterest(interest, data);
+ if (m_validator != nullptr)
+ m_validator->validate(data,
+ bind(&Logic::onSyncDataValidated, this, _1),
+ bind(&Logic::onSyncDataValidationFailed, this, _1));
+ else
+ onSyncDataValidated(data);
_LOG_DEBUG_ID("<< Logic::onSyncData");
}
@@ -421,7 +410,7 @@
}
void
-Logic::onSyncDataValidated(const Data& data, bool firstData)
+Logic::onSyncDataValidated(const Data& data)
{
Name name = data.getName();
ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
@@ -429,7 +418,7 @@
try {
auto contentBuffer = bzip2::decompress(reinterpret_cast<const char*>(data.getContent().value()),
data.getContent().value_size());
- processSyncData(name, digest, Block(contentBuffer), firstData);
+ processSyncData(name, digest, Block(std::move(contentBuffer)));
}
catch (const std::ios_base::failure& error) {
_LOG_WARN("Error decompressing content of " << data.getName() << " (" << error.what() << ")");
@@ -526,8 +515,7 @@
void
Logic::processSyncData(const Name& name,
ConstBufferPtr digest,
- const Block& syncReplyBlock,
- bool firstData)
+ const Block& syncReplyBlock)
{
_LOG_DEBUG_ID(">> Logic::processSyncData");
DiffStatePtr commit = make_shared<DiffState>();
@@ -577,7 +565,7 @@
return;
}
- if (static_cast<bool>(commit) && !commit->getLeaves().empty() && firstData) {
+ if (static_cast<bool>(commit) && !commit->getLeaves().empty()) {
// state changed and it is safe to express a new interest
time::steady_clock::Duration after = time::milliseconds(m_reexpressionJitter(m_rng));
_LOG_DEBUG_ID("Reschedule sync interest after: " << after);
@@ -644,6 +632,7 @@
Interest interest(m_syncReset);
interest.setMustBeFresh(true);
+ interest.setCanBePrefix(false); // no data is expected
interest.setInterestLifetime(m_resetInterestLifetime);
const ndn::PendingInterestId* pendingInterestId = m_face.expressInterest(interest,
bind(&Logic::onResetData, this, _1, _2),
@@ -681,6 +670,7 @@
Interest interest(interestName);
interest.setMustBeFresh(true);
+ interest.setCanBePrefix(true);
interest.setInterestLifetime(m_syncInterestLifetime);
if (m_outstandingInterestId != nullptr) {
@@ -815,6 +805,7 @@
Interest interest(interestName);
interest.setMustBeFresh(true);
+ interest.setCanBePrefix(true);
interest.setInterestLifetime(m_recoveryInterestLifetime);
const ndn::PendingInterestId* pendingInterestId = m_face.expressInterest(interest,
diff --git a/src/logic.hpp b/src/logic.hpp
index f901bb4..a71080f 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -315,10 +315,9 @@
* This method simply passes the valid reply to processSyncData.
*
* @param data The valid Sync Reply.
- * @param firstData Whether the data is new or that obtained using exclude filter
*/
void
- onSyncDataValidated(const Data& data, bool firstData = true);
+ onSyncDataValidated(const Data& data);
/**
* @brief Process normal Sync Interest
@@ -355,13 +354,11 @@
* @param name The data name of the Sync Reply.
* @param digest The digest in the data name.
* @param syncReplyBlock The content of the Sync Reply.
- * @param firstData Whether the data is new or obtained using exclude filter
*/
void
processSyncData(const Name& name,
ConstBufferPtr digest,
- const Block& syncReplyBlock,
- bool firstData);
+ const Block& syncReplyBlock);
/**
* @brief Insert state diff into log
diff --git a/src/socket.cpp b/src/socket.cpp
index 4468fb7..02725f2 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -177,6 +177,7 @@
Interest interest(interestName);
interest.setMustBeFresh(true);
+ interest.setCanBePrefix(false);
DataValidationErrorCallback failureCallback =
bind(&Socket::onDataValidationFailed, this, _1, _2);
@@ -202,6 +203,7 @@
Interest interest(interestName);
interest.setMustBeFresh(true);
+ interest.setCanBePrefix(false);
m_face.expressInterest(interest,
bind(&Socket::onData, this, _1, _2, dataCallback, failureCallback),