add forwarder node
diff --git a/include/sync-seq-no.h b/include/sync-seq-no.h
index 7814f91..e2ed016 100644
--- a/include/sync-seq-no.h
+++ b/include/sync-seq-no.h
@@ -156,6 +156,13 @@
*/
uint32_t getSeq () const
{ return m_seq; }
+
+ /**
+ * @brief Set sequence number
+ */
+ void
+ setSeq(uint32_t seq)
+ { m_seq = seq; }
private:
bool m_valid;
diff --git a/include/sync-state.h b/include/sync-state.h
index 2c7b43b..54ac9d9 100644
--- a/include/sync-state.h
+++ b/include/sync-state.h
@@ -43,7 +43,7 @@
* No corresponding data msg would be published and no attempt would be made to retrieve the
* data msg
*/
-const string dummyPrefix = "/d0n0t18ak/t0ps8cr8t";
+const std::string forwarderPrefix = "/d0n0t18ak/t0ps8cr8t";
class State;
typedef boost::shared_ptr<State> StatePtr;
diff --git a/model/sync-logic.cc b/model/sync-logic.cc
index c013355..48c1d81 100644
--- a/model/sync-logic.cc
+++ b/model/sync-logic.cc
@@ -293,7 +293,7 @@
BOOST_ASSERT (diffLeaf != 0);
NameInfoConstPtr info = diffLeaf->getInfo();
- if (diffLeaf->getOperation() == UPDATE)
+ if (diffLeaf->getOperation() == UPDATE && info->toString() != forwarderPrefix)
{
SeqNo seq = diffLeaf->getSeq();
@@ -328,7 +328,7 @@
}
else
{
- BOOST_ASSERT (false); // just in case
+ BOOST_ASSERT (info->toString() == forwarderPrefix); // just in case
}
}
@@ -466,8 +466,19 @@
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
m_state->remove(info);
+ // increment the sequence number for the forwarder node
+ NameInfoConstPtr forwarderInfo = StdNameInfo::FindOrCreate(forwarderPrefix);
+ bool inserted = false;
+ bool updated = false;
+ SeqNo oldSeq;
+ tie (inserted, updated, oldSeq) = m_state->update (forwarderInfo, oldSeq);
+ oldSeq.setSeq(oldSeq.getSeq() + 1);
+ m_state->update(info, oldSeq);
+
+
diff = make_shared<DiffState>();
diff->remove(info);
+ diff->update(forwarderInfo, oldSeq);
insertToDiffLog (diff);
}
diff --git a/test/test_sync_logic.cc b/test/test_sync_logic.cc
index 2cfde28..61ca626 100644
--- a/test/test_sync_logic.cc
+++ b/test/test_sync_logic.cc
@@ -76,6 +76,9 @@
Handler h1 ("1");
SyncLogic l1 ("/bcast", bind (&Handler::wrapper, &h1, _1), bind (&Handler::onRemove, &h1, _1));
+
+ std::string oldDigest = l1.getRootDigest();
+
l1.addLocalNames ("/one", 1, 2);
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
@@ -89,8 +92,9 @@
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
BOOST_CHECK_EQUAL (h2.m_map.size (), 1);
- // l1.remove ("/one");
+ l1.remove ("/one");
+ sleep(1);
+ std::string newDigest = l1.getRootDigest();
+ BOOST_CHECK(oldDigest != newDigest);
- // sleep (10);
-// l1.
}