Changeset View
Changeset View
Standalone View
Standalone View
src/blockfilter.h
// Copyright (c) 2018 The Bitcoin Core developers | // Copyright (c) 2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_BLOCKFILTER_H | #ifndef BITCOIN_BLOCKFILTER_H | ||||
#define BITCOIN_BLOCKFILTER_H | #define BITCOIN_BLOCKFILTER_H | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <undo.h> | #include <undo.h> | ||||
#include <util/bytevectorhash.h> | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <set> | #include <unordered_set> | ||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* This implements a Golomb-coded set as defined in BIP 158. It is a | * This implements a Golomb-coded set as defined in BIP 158. It is a | ||||
* compact, probabilistic data structure for testing set membership. | * compact, probabilistic data structure for testing set membership. | ||||
*/ | */ | ||||
class GCSFilter { | class GCSFilter { | ||||
public: | public: | ||||
typedef std::vector<uint8_t> Element; | typedef std::vector<uint8_t> Element; | ||||
typedef std::set<Element> ElementSet; | typedef std::unordered_set<Element, ByteVectorHash> ElementSet; | ||||
struct Params { | struct Params { | ||||
uint64_t m_siphash_k0; | uint64_t m_siphash_k0; | ||||
uint64_t m_siphash_k1; | uint64_t m_siphash_k1; | ||||
uint8_t m_P; //!< Golomb-Rice coding parameter | uint8_t m_P; //!< Golomb-Rice coding parameter | ||||
uint32_t m_M; //!< Inverse false positive rate | uint32_t m_M; //!< Inverse false positive rate | ||||
Params(uint64_t siphash_k0 = 0, uint64_t siphash_k1 = 0, uint8_t P = 0, | Params(uint64_t siphash_k0 = 0, uint64_t siphash_k1 = 0, uint8_t P = 0, | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |