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 const ndn::Name& userPrefix,
35 ndn::time::milliseconds syncReplyFreshness,
39 , m_keyChain(keyChain)
40 , m_scheduler(m_face.getIoService())
41 , m_rng(ndn::random::getRandomNumberEngine())
42 , m_iblt(expectedNumEntries, ibltCompression)
43 , m_segmentPublisher(m_face, m_keyChain)
44 , m_expectedNumEntries(expectedNumEntries)
45 , m_threshold(expectedNumEntries / 2)
46 , m_syncPrefix(syncPrefix)
47 , m_userPrefix(userPrefix)
48 , m_syncReplyFreshness(syncReplyFreshness)
49 , m_ibltCompression(ibltCompression)
50 , m_contentCompression(contentCompression)
72 uint64_t seqNo = it->second;
75 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seqNo);
76 auto hashIt =
m_biMap.right.find(prefixWithSeq);
77 if (hashIt !=
m_biMap.right.end()) {
87 NDN_LOG_DEBUG(
"UpdateSeq: " << prefix <<
" " << seq);
95 NDN_LOG_WARN(
"Prefix not found in m_prefixes");
100 NDN_LOG_WARN(
"Update has lower/equal seq no for prefix, doing nothing!");
107 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(oldSeq);
108 auto hashIt =
m_biMap.right.find(prefixWithSeq);
109 if (hashIt !=
m_biMap.right.end()) {
117 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seq);
119 m_biMap.insert({newHash, prefixWithSeq});
126 NDN_LOG_DEBUG(
"Sending application nack");
128 ndn::Name dataName(name);
130 dataName.appendSegment(0);
131 ndn::Data data(dataName);
132 data.setContentType(ndn::tlv::ContentType_Nack)
134 .setFinalBlock(dataName[-1]);
143 NDN_LOG_ERROR(
"onRegisterFailed(" << prefix <<
"): " << msg);
144 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
ProducerBase(ndn::Face &face, ndn::KeyChain &keyChain, size_t expectedNumEntries, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, CompressionScheme ibltCompression=CompressionScheme::NONE, CompressionScheme contentCompression=CompressionScheme::NONE)
Constructor.
static void onRegisterFailed(const ndn::Name &prefix, const std::string &msg)
Logs a message and throws if setting an interest filter fails.
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