Adding special processing for 0 (zero-root) digest
diff --git a/model/sync-digest.cc b/model/sync-digest.cc
index 705a467..6da6e78 100644
--- a/model/sync-digest.cc
+++ b/model/sync-digest.cc
@@ -166,12 +166,16 @@
if (m_buffer == 0)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has not been yet finalized"));
- // finalize ();
+ if (m_hashLength == 1 && m_buffer[0] == 0)
+ return 0;
+
if (sizeof (std::size_t) > m_hashLength)
- BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
- << errmsg_info_str ("Hash length is less than size_t")
- << errmsg_info_int (m_hashLength));
+ {
+ BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
+ << errmsg_info_str ("Hash is not zero and length is less than size_t")
+ << errmsg_info_int (m_hashLength));
+ }
// just getting first sizeof(std::size_t) bytes
// not ideal, but should work pretty well
@@ -190,10 +194,13 @@
<< errmsg_info_str ("Digest2 is empty"));
if (m_hashLength != digest.m_hashLength)
- BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
- << errmsg_info_str ("Digest lengths are not the same")
- << errmsg_info_int (m_hashLength)
- << errmsg_info_int (digest.m_hashLength));
+ return false;
+
+ // Allow different hash size
+ // BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
+ // << errmsg_info_str ("Digest lengths are not the same")
+ // << errmsg_info_int (m_hashLength)
+ // << errmsg_info_int (digest.m_hashLength));
return memcmp (m_buffer, digest.m_buffer, m_hashLength) == 0;
}
diff --git a/model/sync-full-state.cc b/model/sync-full-state.cc
index d01460e..baac098 100644
--- a/model/sync-full-state.cc
+++ b/model/sync-full-state.cc
@@ -72,7 +72,6 @@
FullLeafConstPtr fullLeaf = dynamic_pointer_cast<const FullLeaf> (leaf);
BOOST_ASSERT (fullLeaf != 0);
*m_digest << fullLeaf->getDigest ();
- // std::cout << *leaf << "[" << fullLeaf->getDigest () << "] ";
}
m_digest->finalize ();
}
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index cd74f2b..0f71b95 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -118,7 +118,7 @@
void
SyncLogic::processSyncData (const string &name, const string &dataBuffer)
{
- //cout << "Process Sync Data" <<endl;
+ //cout << "Process Sync Data" <<endl;
DiffStatePtr diffLog = make_shared<DiffState> ();
try
@@ -211,41 +211,41 @@
void
SyncLogic::processPendingSyncInterests (DiffStatePtr &diffLog)
{
- //cout << "Process Pending Interests" <<endl;
+ //cout << "Process Pending Interests" <<endl;
recursive_mutex::scoped_lock lock (m_stateMutex);
- diffLog->setDigest(m_state.getDigest());
- if (m_log.size () > 0)
+ diffLog->setDigest (m_state.getDigest());
+ if (m_log.get<sequenced> ().size () > 0)
{
m_log.get<sequenced> ().front ()->setNext (diffLog);
}
- m_log.insert (diffLog);
+ m_log.get<sequenced> ().push_back (diffLog);
vector<string> pis = m_syncInterestTable.fetchAll ();
if (pis.size () > 0)
{
- stringstream ss;
+ stringstream ss;
ss << *diffLog;
- for (vector<string>::iterator ii = pis.begin(); ii != pis.end(); ++ii)
- {
- m_ccnxHandle->publishData (*ii, ss.str(), m_syncResponseFreshness);
- }
-}
+ for (vector<string>::iterator ii = pis.begin(); ii != pis.end(); ++ii)
+ {
+ m_ccnxHandle->publishData (*ii, ss.str(), m_syncResponseFreshness);
+ }
+ }
}
void
SyncLogic::addLocalNames (const string &prefix, uint32_t session, uint32_t seq)
{
- //cout << "Add local names" <<endl;
+ //cout << "Add local names" <<endl;
recursive_mutex::scoped_lock lock (m_stateMutex);
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
- SeqNo seqN(session, seq);
+
+ SeqNo seqN (session, seq);
m_state.update(info, seqN);
DiffStatePtr diff = make_shared<DiffState>();
diff->update(info, seqN);
-
- processPendingSyncInterests(diff);
+ processPendingSyncInterests (diff);
}
void
@@ -258,7 +258,7 @@
DiffStatePtr diff = make_shared<DiffState>();
diff->remove(info);
- processPendingSyncInterests(diff);
+ processPendingSyncInterests (diff);
}
void