diff options
Diffstat (limited to 'src/blockfilter.h')
-rw-r--r-- | src/blockfilter.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/blockfilter.h b/src/blockfilter.h index d45d31046f..afb8d7a7b7 100644 --- a/src/blockfilter.h +++ b/src/blockfilter.h @@ -9,8 +9,10 @@ #include <stdint.h> #include <vector> +#include <primitives/block.h> #include <serialize.h> #include <uint256.h> +#include <undo.h> /** * This implements a Golomb-coded set as defined in BIP 158. It is a @@ -71,4 +73,37 @@ public: bool MatchAny(const ElementSet& elements) const; }; +constexpr uint8_t BASIC_FILTER_P = 19; +constexpr uint32_t BASIC_FILTER_M = 784931; + +enum BlockFilterType : uint8_t +{ + BASIC = 0, +}; + +/** + * Complete block filter struct as defined in BIP 157. + */ +class BlockFilter +{ +private: + BlockFilterType m_filter_type; + uint256 m_block_hash; + GCSFilter m_filter; + +public: + + // Construct a new BlockFilter of the specified type from a block. + BlockFilter(BlockFilterType filter_type, const CBlock& block, const CBlockUndo& block_undo); + + BlockFilterType GetFilterType() const { return m_filter_type; } + + const GCSFilter& GetFilter() const { return m_filter; } + + const std::vector<unsigned char>& GetEncodedFilter() const + { + return m_filter.GetEncoded(); + } +}; + #endif // BITCOIN_BLOCKFILTER_H |