sync: removed ref to lsdb.
Sync now emits to a signal whenever a new LSA is detected, and the LSDB
listens to this signal. Sync consults a function object gotten at ctor time
to determine LSA newness. This means Sync no longer needs a reference to
the LSDB, and LSA newness criteria can be freely manipulated.
Change-Id: Ifce3ebfc921ad846fcfa12d99c78f3b337180827
refs: #4264
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 3fed788..4de69ef 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -65,10 +65,35 @@
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler)
: m_nlsr(nlsr)
, m_scheduler(scheduler)
- , m_sync(m_nlsr.getNlsrFace(), *this, m_nlsr.getConfParameter())
+ , m_sync(m_nlsr.getNlsrFace(),
+ [this] (const ndn::Name& routerName, const std::string& lsaType,
+ const uint64_t& sequenceNumber) {
+ ndn::Name lsaKey = routerName;
+ lsaKey.append(lsaType);
+
+ if (lsaType == NameLsa::TYPE_STRING) {
+ return isNameLsaNew(lsaKey, sequenceNumber);
+ }
+ else if (lsaType == AdjLsa::TYPE_STRING) {
+ return isAdjLsaNew(lsaKey, sequenceNumber);
+ }
+ else if (lsaType == CoordinateLsa::TYPE_STRING) {
+ return isCoordinateLsaNew(lsaKey, sequenceNumber);
+ }
+ else {
+ return false;
+ }
+ },
+ m_nlsr.getConfParameter())
, m_lsaRefreshTime(0)
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
, m_sequencingManager()
+ , m_onNewLsaConnection(m_sync.onNewLsa->connect(
+ [this] (const ndn::Name& updateName, const uint64_t& sequenceNumber) {
+ ndn::Name lsaInterest{updateName};
+ lsaInterest.appendNumber(sequenceNumber);
+ expressInterest(lsaInterest, 0);
+ }))
{
}