build: == Dependency change == ChronoSync now depends on ndn-cxx library
diff --git a/src/sync-logic.cc b/src/sync-logic.cc
index 56692e5..86fb69b 100644
--- a/src/sync-logic.cc
+++ b/src/sync-logic.cc
@@ -17,7 +17,7 @@
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Yingdi Yu <yingdi@cs.ucla.edu>
*/
@@ -61,7 +61,7 @@
SyncLogic::SyncLogic (const Name& syncPrefix,
const IdentityCertificate& myCertificate,
- shared_ptr<Validator> validator,
+ shared_ptr<Validator> validator,
shared_ptr<Face> face,
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove)
@@ -79,11 +79,11 @@
, m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
, m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
, m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
-{
- m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
- bind(&SyncLogic::onSyncInterest, this, _1, _2),
+{
+ m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
+ bind(&SyncLogic::onSyncInterest, this, _1, _2),
bind(&SyncLogic::onSyncRegisterFailed, this, _1, _2));
-
+
m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
bind (&SyncLogic::sendSyncInterest, this));
@@ -109,9 +109,9 @@
, m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
, m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
, m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
-{
- m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
- bind(&SyncLogic::onSyncInterest, this, _1, _2),
+{
+ m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
+ bind(&SyncLogic::onSyncInterest, this, _1, _2),
bind(&SyncLogic::onSyncRegisterFailed, this, _1, _2));
m_reexpressingInterestId = m_scheduler.scheduleEvent (time::seconds (0), // no need to add jitter
@@ -119,8 +119,8 @@
}
SyncLogic::~SyncLogic ()
-{
- m_face->unsetInterestFilter(m_syncRegisteredPrefixId);
+{
+ m_face->unsetInterestFilter(m_syncRegisteredPrefixId);
m_scheduler.cancelEvent (m_reexpressingInterestId);
m_scheduler.cancelEvent (m_delayedInterestProcessingId);
}
@@ -128,7 +128,7 @@
/**
* Two types of intersts
*
- * Normal name: .../<hash>
+ * Normal name: .../<hash>
* Recovery name: .../recovery/<hash>
*/
boost::tuple<DigestConstPtr, std::string>
@@ -139,10 +139,10 @@
int nameLengthDiff = name.size() - m_syncPrefix.size();
BOOST_ASSERT (nameLengthDiff > 0);
BOOST_ASSERT (nameLengthDiff < 3);
-
+
std::string hash = name.get(-1).toEscapedString();
std::string interestType;
-
+
if(nameLengthDiff == 1)
interestType = "normal";
else
@@ -180,7 +180,7 @@
{
processSyncInterest (name, digest);
}
- else if (type == "recovery")
+ else if (type == "recovery")
{
processSyncRecoveryInterest (name, digest);
}
@@ -204,13 +204,13 @@
{
OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
- m_validator->validate(data, onValidated, onValidationFailed);
+ m_validator->validate(data, onValidated, onValidationFailed);
}
void
SyncLogic::onSyncTimeout(const ndn::Interest& interest)
-{
- // It is OK. Others will handle the time out situation.
+{
+ // It is OK. Others will handle the time out situation.
}
void
@@ -229,7 +229,7 @@
try
{
_LOG_DEBUG_ID ("<< D " << name);
-
+
DigestConstPtr digest;
std::string type;
tie (digest, type) = convertNameToDigestAndType (name);
@@ -265,7 +265,7 @@
// Special case when state is not empty and we have received request with zero-root digest
if (digest->isZero () && !rootDigest->isZero ())
{
-
+
SyncStateMsg ssm;
{
ssm << (*m_state);
@@ -280,7 +280,7 @@
m_syncInterestTable.insert (digest, name.toUri(), false);
return;
}
-
+
DiffStateContainer::iterator stateInDiffLog = m_log.find (digest);
if (stateInDiffLog != m_log.end ())
@@ -300,7 +300,7 @@
m_scheduler.cancelEvent (m_delayedInterestProcessingId);
}
- uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);
+ uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);
_LOG_DEBUG_ID ("Digest is not in the log. Schedule processing after small delay: " << time::milliseconds (waitDelay));
m_delayedInterestProcessingId = m_scheduler.scheduleEvent (time::milliseconds (waitDelay),
@@ -309,7 +309,7 @@
else
{
_LOG_DEBUG_ID (" (timed processing)");
-
+
m_recoveryRetransmissionInterval = m_defaultRecoveryRetransmitInterval;
sendSyncRecoveryInterests (digest);
}
@@ -320,7 +320,7 @@
{
DiffStatePtr diffLog = boost::make_shared<DiffState> ();
bool ownInterestSatisfied = false;
-
+
try
{
@@ -330,7 +330,7 @@
DiffState diff;
SyncStateMsg msg;
- if (!msg.ParseFromArray(wireData, len) || !msg.IsInitialized())
+ if (!msg.ParseFromArray(wireData, len) || !msg.IsInitialized())
{
//Throw
BOOST_THROW_EXCEPTION (Error::SyncStateMsgDecodingFailure () );
@@ -404,7 +404,7 @@
}
}
- if (!v.empty())
+ if (!v.empty())
{
if (!m_perBranch)
{
@@ -430,7 +430,7 @@
// this is kind of wrong
// satisfyPendingSyncInterests (diffLog); // if there are interests in PIT, there is a point to satisfy them using new state
-
+
// if state has changed, then it is safe to express a new interest
time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
@@ -472,7 +472,7 @@
/// @todo Impose limit on how many state info should be send out
}
}
-
+
try
{
uint32_t counter = 0;
@@ -501,9 +501,9 @@
}
void
-SyncLogic::insertToDiffLog (DiffStatePtr diffLog)
+SyncLogic::insertToDiffLog (DiffStatePtr diffLog)
{
- diffLog->setDigest (m_state->getDigest());
+ diffLog->setDigest (m_state->getDigest());
if (m_log.size () > 0)
{
m_log.get<sequenced> ().front ()->setNext (diffLog);
@@ -527,23 +527,23 @@
m_state->update(info, seqN);
_LOG_DEBUG_ID ("addLocalNames (): new state " << *m_state->getDigest ());
-
+
diff = boost::make_shared<DiffState>();
diff->update(info, seqN);
insertToDiffLog (diff);
}
// _LOG_DEBUG_ID ("PIT size: " << m_syncInterestTable.size ());
- satisfyPendingSyncInterests (diff);
+ satisfyPendingSyncInterests (diff);
}
void
-SyncLogic::remove(const Name &prefix)
+SyncLogic::remove(const Name &prefix)
{
DiffStatePtr diff;
{
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix.toUri());
- m_state->remove(info);
+ m_state->remove(info);
// increment the sequence number for the forwarder node
NameInfoConstPtr forwarderInfo = StdNameInfo::FindOrCreate(forwarderPrefix);
@@ -564,7 +564,7 @@
insertToDiffLog (diff);
}
- satisfyPendingSyncInterests (diff);
+ satisfyPendingSyncInterests (diff);
}
void
@@ -600,14 +600,14 @@
{
std::ostringstream os;
os << *digest;
-
+
Name interestName = m_syncPrefix;
interestName.append("recovery").append(os.str());
time::system_clock::Duration nextRetransmission = time::milliseconds (m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
m_recoveryRetransmissionInterval <<= 1;
-
+
m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
if (m_recoveryRetransmissionInterval < 100*1000) // <100 seconds
m_reexpressingRecoveryInterestId = m_scheduler.scheduleEvent (nextRetransmission,
@@ -643,11 +643,11 @@
Data syncData(name);
syncData.setContent(reinterpret_cast<const uint8_t*>(wireData), size);
syncData.setFreshnessPeriod(time::milliseconds(m_syncResponseFreshness));
-
+
m_keyChain.sign(syncData, m_myCertificate.getName());
-
+
m_face->put(syncData);
-
+
delete []wireData;
// checking if our own interest got satisfied
@@ -655,11 +655,11 @@
{
satisfiedOwnInterest = (m_outstandingInterestName == name);
}
-
+
if (satisfiedOwnInterest)
{
_LOG_DEBUG_ID ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
-
+
time::system_clock::Duration after = time::milliseconds(GET_RANDOM (m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
EventId eventId = m_scheduler.scheduleEvent (after,
@@ -670,7 +670,7 @@
}
std::string
-SyncLogic::getRootDigest()
+SyncLogic::getRootDigest()
{
std::ostringstream os;
os << *m_state->getDigest();