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 <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <undo.h> | #include <undo.h> | ||||
#include <util/bytevectorhash.h> | #include <util/bytevectorhash.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <string> | |||||
#include <unordered_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 { | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
constexpr uint8_t BASIC_FILTER_P = 19; | constexpr uint8_t BASIC_FILTER_P = 19; | ||||
constexpr uint32_t BASIC_FILTER_M = 784931; | constexpr uint32_t BASIC_FILTER_M = 784931; | ||||
enum class BlockFilterType : uint8_t { | enum class BlockFilterType : uint8_t { | ||||
BASIC = 0, | BASIC = 0, | ||||
INVALID = 255, | INVALID = 255, | ||||
}; | }; | ||||
/** Get the human-readable name for a filter type. Returns empty string for | |||||
* unknown types. */ | |||||
const std::string &BlockFilterTypeName(BlockFilterType filter_type); | |||||
/** Find a filter type by its human-readable name. */ | |||||
bool BlockFilterTypeByName(const std::string &name, | |||||
BlockFilterType &filter_type); | |||||
/** | /** | ||||
* Complete block filter struct as defined in BIP 157. Serialization matches | * Complete block filter struct as defined in BIP 157. Serialization matches | ||||
* payload of "cfilter" messages. | * payload of "cfilter" messages. | ||||
*/ | */ | ||||
class BlockFilter { | class BlockFilter { | ||||
private: | private: | ||||
BlockFilterType m_filter_type = BlockFilterType::INVALID; | BlockFilterType m_filter_type = BlockFilterType::INVALID; | ||||
BlockHash m_block_hash; | BlockHash m_block_hash; | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |