5#ifndef BITCOIN_SHORTIDPROCESSOR_H
6#define BITCOIN_SHORTIDPROCESSOR_H
12#include <unordered_map>
16template <
typename PrefilledItemType,
typename Adapter,
typename ItemCompare>
18 using ItemType =
typename std::remove_reference<
19 decltype(std::declval<Adapter &>().getItem(
20 std::declval<PrefilledItemType &>()))>::type;
56 const std::vector<uint64_t> &
shortids,
67 for (
size_t i = 0; i <
shortids.size(); i++) {
int addItem(uint32_t index, const ItemType &item)
const ItemType & getItem(size_t index) const
bool isEvenlyDistributed() const
Status accessors.
typename std::remove_reference< decltype(std::declval< Adapter & >().getItem(std::declval< PrefilledItemType & >()))>::type ItemType
size_t getItemCount() const
Total item count.
int matchKnownItem(uint64_t shortid, const ItemType &item)
Attempts to add a known item by matching its shortid with the supplied ones.
std::unordered_map< uint64_t, uint32_t > shortIdIndexMap
ShortIdProcessor(const std::vector< PrefilledItemType > &prefilledItems, const std::vector< uint64_t > &shortids, size_t maxShortIdPerBucket)
size_t getShortIdCount() const
Unique shortid count.
std::vector< ItemType > itemsAvailable
bool hasShortIdCollision() const
std::vector< bool > haveItem
bool hasOutOfBoundIndex() const
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...