aboutsummaryrefslogtreecommitdiff
path: root/src/blockfilter.h
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2018-01-23 17:25:30 -0800
committerJim Posen <jim.posen@gmail.com>2018-08-25 10:02:37 -0700
commitc1855f6052aca806fdb51be01b30dfeee8b55f40 (patch)
tree7bfbd95109be83236777956b9465727eba5cd3da /src/blockfilter.h
parent53e7874e079f9ddfe8b176f11d46e6b59c7283d5 (diff)
downloadbitcoin-c1855f6052aca806fdb51be01b30dfeee8b55f40.tar.xz
blockfilter: Construction of basic block filters.
Diffstat (limited to 'src/blockfilter.h')
-rw-r--r--src/blockfilter.h35
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