20 #ifndef PSYNC_FULL_PRODUCER_HPP
21 #define PSYNC_FULL_PRODUCER_HPP
28 #include <ndn-cxx/util/segment-fetcher.hpp>
72 ndn::KeyChain& keyChain,
73 const ndn::Name& syncPrefix,
78 ndn::KeyChain& keyChain,
79 size_t expectedNumEntries,
80 const ndn::Name& syncPrefix,
81 const ndn::Name& userPrefix,
102 publishName(
const ndn::Name& prefix, std::optional<uint64_t> seq = std::nullopt);
116 processWaitingInterests();
119 scheduleProcessWaitingInterests();
137 onSyncInterest(
const ndn::Name& prefixName,
const ndn::Interest& interest,
138 bool isTimedProcessing =
false);
152 sendSyncData(
const ndn::Name& name,
const ndn::Block& block,
153 ndn::time::milliseconds syncReplyFreshness);
171 onSyncData(
const ndn::Interest& interest,
const ndn::ConstBufferPtr& bufferPtr);
184 satisfyPendingInterests(
const ndn::Name& updatedPrefixWithSeq);
190 deletePendingInterests(
const ndn::Name& interestName);
199 isFutureHash(
const ndn::Name& prefix,
const std::set<uint32_t>& negative);
201 #ifdef PSYNC_WITH_TESTS
203 size_t nIbfDecodeFailuresAboveThreshold = 0;
204 size_t nIbfDecodeFailuresBelowThreshold = 0;
208 struct PendingEntryInfo
211 ndn::scheduler::ScopedEventId expirationEvent;
214 struct WaitingEntryInfo
216 uint16_t numTries = 0;
217 ndn::Interest::Nonce nonce;
220 ndn::time::milliseconds m_syncInterestLifetime;
222 ndn::scheduler::ScopedEventId m_scheduledSyncInterestId;
223 static constexpr
int MIN_JITTER = 100;
224 static constexpr
int MAX_JITTER = 500;
225 std::uniform_int_distribution<> m_jitter{MIN_JITTER, MAX_JITTER};
226 ndn::time::system_clock::time_point m_lastInterestSentTime;
227 ndn::Name m_outstandingInterestName;
228 ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;
229 std::shared_ptr<ndn::SegmentFetcher> m_fetcher;
230 uint64_t m_incomingFace = 0;
231 std::map<ndn::Name, WaitingEntryInfo> m_waitingForProcessing;
232 bool m_inNoNewDataWaitOutPeriod =
false;
233 ndn::scheduler::ScopedEventId m_interestDelayTimerId;
236 std::map<ndn::Name, PendingEntryInfo> m_pendingEntries;
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Full sync logic to synchronize with other nodes where all nodes wants to get all names prefixes synce...
void publishName(const ndn::Name &prefix, std::optional< uint64_t > seq=std::nullopt)
Publish name to let others know.
FullProducer(ndn::Face &face, ndn::KeyChain &keyChain, const ndn::Name &syncPrefix, const Options &opts)
Constructor.
Base class for PartialProducer and FullProducer.
Invertible Bloom Lookup Table (Invertible Bloom Filter)
constexpr ndn::time::milliseconds SYNC_INTEREST_LIFETIME
constexpr ndn::time::milliseconds SYNC_REPLY_FRESHNESS
std::function< void(const std::vector< MissingDataInfo > &)> UpdateCallback
uint32_t ibfCount
Expected number of entries in IBF.
UpdateCallback onUpdate
Callback to be invoked when there is new data.
ndn::time::milliseconds syncInterestLifetime
Lifetime of sync Interest.
ndn::time::milliseconds syncDataFreshness
FreshnessPeriod of sync Data.
CompressionScheme ibfCompression
Compression scheme to use for IBF.
CompressionScheme contentCompression
Compression scheme to use for Data content.