29 #ifdef HAVE_CHRONOSYNC
30 const auto FIXED_SESSION = ndn::name::Component::fromNumber(0);
34 ndn::KeyChain& keyChain,
36 const ndn::Name& syncPrefix,
37 const ndn::Name& userPrefix,
38 ndn::time::milliseconds syncInterestLifetime,
40 : m_syncProtocol(syncProtocol)
41 , m_syncUpdateCallback(std::move(syncUpdateCallback))
43 switch (m_syncProtocol) {
44 #ifdef HAVE_CHRONOSYNC
46 NDN_LOG_DEBUG(
"Using ChronoSync");
47 m_chronoSyncLogic = std::make_shared<chronosync::Logic>(face,
50 [
this] (
auto&&... args) { onChronoSyncUpdate(std::forward<decltype(args)>(args)...); },
51 chronosync::Logic::DEFAULT_NAME,
52 chronosync::Logic::DEFAULT_VALIDATOR,
53 chronosync::Logic::DEFAULT_RESET_TIMER,
54 chronosync::Logic::DEFAULT_CANCEL_RESET_TIMER,
55 chronosync::Logic::DEFAULT_RESET_INTEREST_LIFETIME,
57 chronosync::Logic::DEFAULT_SYNC_REPLY_FRESHNESS,
58 chronosync::Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
64 NDN_LOG_DEBUG(
"Using PSync");
65 m_psyncLogic = std::make_shared<psync::FullProducer>(face,
70 [
this] (
auto&&... args) { onPSyncUpdate(std::forward<decltype(args)>(args)...); },
71 syncInterestLifetime);
76 NDN_LOG_DEBUG(
"Using SVS");
77 m_svsCore = std::make_shared<ndn::svs::SVSyncCore>(face,
79 [
this] (
auto&&... args) { onSvsUpdate(std::forward<decltype(args)>(args)...); });
90 switch (m_syncProtocol) {
91 #ifdef HAVE_CHRONOSYNC
93 m_chronoSyncLogic->addUserNode(userPrefix, chronosync::Logic::DEFAULT_NAME, FIXED_SESSION);
98 m_psyncLogic->addUserNode(userPrefix);
113 switch (m_syncProtocol) {
114 #ifdef HAVE_CHRONOSYNC
116 m_chronoSyncLogic->updateSeqNo(seq, userPrefix);
121 m_psyncLogic->publishName(userPrefix, seq);
126 m_svsCore->updateSeqNo(seq, userPrefix);
134 #ifdef HAVE_CHRONOSYNC
136 SyncProtocolAdapter::onChronoSyncUpdate(
const std::vector<chronosync::MissingDataInfo>& updates)
140 for (
const auto& update : updates) {
142 m_syncUpdateCallback(update.session.getPrefix(-1), update.high, 0);
149 SyncProtocolAdapter::onPSyncUpdate(
const std::vector<psync::MissingDataInfo>& updates)
153 for (
const auto& update : updates) {
154 m_syncUpdateCallback(update.prefix, update.highSeq, update.incomingFace);
161 SyncProtocolAdapter::onSvsUpdate(
const std::vector<ndn::svs::MissingDataInfo>& updates)
165 for (
const auto& update : updates) {
166 m_syncUpdateCallback(update.nodeId, update.high, update.incomingFace);
void publishUpdate(const ndn::Name &userPrefix, uint64_t seq)
Publish update to Sync.
SyncProtocolAdapter(ndn::Face &face, ndn::KeyChain &keyChain, SyncProtocol syncProtocol, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncInterestLifetime, SyncUpdateCallback syncUpdateCallback)
void addUserNode(const ndn::Name &userPrefix)
Add user node to Sync.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define INIT_LOGGER(name)
#define NLSR_LOG_TRACE(x)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::function< void(const ndn::Name &updateName, uint64_t seqNo, uint64_t incomingFaceId)> SyncUpdateCallback