5 #ifndef BITCOIN_BLOCKFILTER_H 6 #define BITCOIN_BLOCKFILTER_H 13 #include <unordered_set> 31 typedef std::vector<unsigned char>
Element;
32 typedef std::unordered_set<Element, ByteVectorHash>
ElementSet;
41 Params(uint64_t siphash_k0 = 0, uint64_t siphash_k1 = 0, uint8_t P = 0, uint32_t
M = 1)
58 bool MatchInternal(
const uint64_t* sorted_element_hashes,
size_t size)
const;
66 GCSFilter(
const Params& params, std::vector<unsigned char> encoded_filter,
bool skip_decode_check);
129 std::vector<unsigned char> filter,
bool skip_decode_check);
149 template <
typename Stream>
156 template <
typename Stream>
158 std::vector<unsigned char> encoded_filter;
169 throw std::ios_base::failure(
"unknown filter_type");
175 #endif // BITCOIN_BLOCKFILTER_H const GCSFilter & GetFilter() const LIFETIMEBOUND
const std::set< BlockFilterType > & AllBlockFilterTypes()
Get a list of known filter types.
constexpr uint32_t BASIC_FILTER_M
const std::string & BlockFilterTypeName(BlockFilterType filter_type)
Get the human-readable name for a filter type.
const Params & GetParams() const LIFETIMEBOUND
constexpr uint8_t BASIC_FILTER_P
bool MatchAny(const ElementSet &elements) const
Checks if any of the given elements may be in the set.
bool BlockFilterTypeByName(const std::string &name, BlockFilterType &filter_type)
Find a filter type by its human-readable name.
std::vector< uint64_t > BuildHashedSet(const ElementSet &elements) const
uint256 GetHash() const
Compute the filter hash.
bool Match(const Element &element) const
Checks if the element may be in the set.
GCSFilter(const Params ¶ms=Params())
Constructs an empty filter.
const uint256 & GetBlockHash() const LIFETIMEBOUND
void Serialize(Stream &s) const
bool MatchInternal(const uint64_t *sorted_element_hashes, size_t size) const
Helper method used to implement Match and MatchAny.
Complete block filter struct as defined in BIP 157.
uint64_t HashToRange(const Element &element) const
Hash a data element to an integer in the range [0, N * M).
const std::string & ListBlockFilterTypes()
Get a comma-separated list of known filter type names.
This implements a Golomb-coded set as defined in BIP 158.
std::unordered_set< Element, ByteVectorHash > ElementSet
uint32_t m_M
Inverse false positive rate.
uint256 ComputeHeader(const uint256 &prev_header) const
Compute the filter header given the previous one.
uint8_t m_P
Golomb-Rice coding parameter.
Params(uint64_t siphash_k0=0, uint64_t siphash_k1=0, uint8_t P=0, uint32_t M=1)
const CChainParams & Params()
Return the currently selected parameters.
Undo information for a CBlock.
BlockFilterType m_filter_type
std::vector< unsigned char > Element
const std::vector< unsigned char > & GetEncodedFilter() const LIFETIMEBOUND
uint32_t m_N
Number of elements in the filter.
BlockFilterType GetFilterType() const
uint64_t m_F
Range of element hashes, F = N * M.
const std::vector< unsigned char > & GetEncoded() const LIFETIMEBOUND
bool BuildParams(GCSFilter::Params ¶ms) const
std::vector< unsigned char > m_encoded
void Unserialize(Stream &s)