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;
69 ndn::KeyChain& keyChain,
70 size_t expectedNumEntries,
71 const ndn::Name& syncPrefix,
82 std::optional<uint64_t>
129 updateSeqNo(
const ndn::Name& prefix, uint64_t seq);
151 [[noreturn]]
static void
158 ndn::random::RandomNumberEngine&
m_rng;
166 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
uint64_t m_numOwnElements
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
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.
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