23 #include <ndn-cxx/util/exception.hpp>
24 #include <ndn-cxx/util/logger.hpp>
31 ndn::KeyChain& keyChain,
32 size_t expectedNumEntries,
33 const ndn::Name& syncPrefix,
34 ndn::time::milliseconds syncReplyFreshness,
38 , m_keyChain(keyChain)
39 , m_scheduler(m_face.getIoContext())
40 , m_rng(ndn::random::getRandomNumberEngine())
41 , m_iblt(expectedNumEntries, ibltCompression)
42 , m_segmentPublisher(m_face, m_keyChain)
43 , m_expectedNumEntries(expectedNumEntries)
44 , m_threshold(expectedNumEntries / 2)
45 , m_syncPrefix(syncPrefix)
46 , m_syncReplyFreshness(syncReplyFreshness)
47 , m_ibltCompression(ibltCompression)
48 , m_contentCompression(contentCompression)
69 uint64_t seqNo = it->second;
72 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seqNo);
73 auto hashIt =
m_biMap.right.find(prefixWithSeq);
74 if (hashIt !=
m_biMap.right.end()) {
84 NDN_LOG_DEBUG(
"UpdateSeq: " << prefix <<
" " << seq);
92 NDN_LOG_WARN(
"Prefix not found in m_prefixes");
97 NDN_LOG_WARN(
"Update has lower/equal seq no for prefix, doing nothing!");
104 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(oldSeq);
105 auto hashIt =
m_biMap.right.find(prefixWithSeq);
106 if (hashIt !=
m_biMap.right.end()) {
114 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seq);
116 m_biMap.insert({newHash, prefixWithSeq});
125 NDN_LOG_DEBUG(
"Sending application nack");
127 ndn::Name dataName(name);
129 dataName.appendSegment(0);
130 ndn::Data data(dataName);
131 data.setContentType(ndn::tlv::ContentType_Nack)
133 .setFinalBlock(dataName[-1]);
142 NDN_LOG_ERROR(
"onRegisterFailed(" << prefix <<
"): " << msg);
143 NDN_THROW(
Error(msg));
Base class for PartialProducer and FullProducer.
void sendApplicationNack(const ndn::Name &name)
Sends a data packet with content type nack.
const ndn::time::milliseconds m_syncReplyFreshness
void removeUserNode(const ndn::Name &prefix)
Remove the user node from synchronization.
bool addUserNode(const ndn::Name &prefix)
Adds a user node for synchronization.
std::map< ndn::Name, uint64_t > m_prefixes
uint64_t m_numOwnElements
static void onRegisterFailed(const ndn::Name &prefix, const std::string &msg)
Logs a message and throws if setting an interest filter fails.
ProducerBase(ndn::Face &face, ndn::KeyChain &keyChain, size_t expectedNumEntries, const ndn::Name &syncPrefix, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, CompressionScheme ibltCompression=CompressionScheme::NONE, CompressionScheme contentCompression=CompressionScheme::NONE)
Constructor.
void updateSeqNo(const ndn::Name &prefix, uint64_t seq)
Update m_prefixes and IBF with the given prefix and seq.
ndn::KeyChain & m_keyChain
void insert(uint32_t key)
void appendToName(ndn::Name &name) const
Appends self to name.
uint32_t murmurHash3(const void *key, size_t len, uint32_t seed)
constexpr size_t N_HASHCHECK