20 #ifndef PSYNC_PRODUCER_BASE_HPP
21 #define PSYNC_PRODUCER_BASE_HPP
28 #include <ndn-cxx/face.hpp>
29 #include <ndn-cxx/security/key-chain.hpp>
30 #include <ndn-cxx/util/random.hpp>
31 #include <ndn-cxx/util/scheduler.hpp>
33 #include <boost/bimap/bimap.hpp>
34 #include <boost/bimap/unordered_set_of.hpp>
40 namespace bm = boost::bimaps;
50 class Error :
public std::runtime_error
53 using std::runtime_error::runtime_error;
70 ndn::KeyChain& keyChain,
71 size_t expectedNumEntries,
72 const ndn::Name& syncPrefix,
73 const ndn::Name& userPrefix,
84 std::optional<uint64_t>
131 updateSeqNo(
const ndn::Name& prefix, uint64_t seq);
153 [[noreturn]]
static void
160 ndn::random::RandomNumberEngine&
m_rng;
168 bm::unordered_set_of<ndn::Name, std::hash<ndn::Name>>>;
#define PSYNC_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Base class for PartialProducer and FullProducer.
const CompressionScheme m_contentCompression
void sendApplicationNack(const ndn::Name &name)
Sends a data packet with content type nack.
const ndn::Name m_syncPrefix
std::optional< uint64_t > getSeqNo(const ndn::Name &prefix) const
Returns the current sequence number of the given prefix.
const ndn::time::milliseconds m_syncReplyFreshness
void removeUserNode(const ndn::Name &prefix)
Remove the user node from synchronization.
const size_t m_expectedNumEntries
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.
const ndn::Name m_userPrefix
ndn::Scheduler m_scheduler
static void onRegisterFailed(const ndn::Name &prefix, const std::string &msg)
Logs a message and throws if setting an interest filter fails.
bool isUserNode(const ndn::Name &prefix) const
const CompressionScheme m_ibltCompression
void updateSeqNo(const ndn::Name &prefix, uint64_t seq)
Update m_prefixes and IBF with the given prefix and seq.
bm::bimap< bm::unordered_set_of< uint32_t >, bm::unordered_set_of< ndn::Name, std::hash< ndn::Name > >> HashNameBiMap
SegmentPublisher m_segmentPublisher
ndn::KeyChain & m_keyChain
ndn::random::RandomNumberEngine & m_rng
Helper class to publish segmented data.
Invertible Bloom Lookup Table (Invertible Bloom Filter)
constexpr ndn::time::milliseconds SYNC_REPLY_FRESHNESS