6#ifndef BITCOIN_MERKLEBLOCK_H
7#define BITCOIN_MERKLEBLOCK_H
17std::vector<uint8_t>
BitsToBytes(
const std::vector<bool> &bits);
18std::vector<bool>
BytesToBits(
const std::vector<uint8_t> &bytes);
82 uint256 CalcHash(
int height,
size_t pos,
const std::vector<uint256> &vTxid);
89 const std::vector<uint256> &vTxid,
90 const std::vector<bool> &vMatch);
98 size_t &nHashUsed, std::vector<uint256> &vMatch,
99 std::vector<size_t> &vnIndex);
104 std::vector<uint8_t> bytes;
116 const std::vector<bool> &vMatch);
126 std::vector<size_t> &vnIndex);
185 const std::set<TxId> *txids);
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Used to create a Merkle proof (usually from a subset of transactions), which consists of a block head...
SERIALIZE_METHODS(CMerkleBlock, obj)
CMerkleBlock(const CBlock &block, const std::set< TxId > &txids)
Create a Merkle proof for a set of transactions.
CBlockHeader header
Public only for unit testing.
CMerkleBlock(const CBlock &block, CBloomFilter &filter)
Create a Merkle proof according to a bloom filter.
std::vector< std::pair< size_t, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed).
Data structure that represents a partial merkle tree.
uint32_t nTransactions
the total number of transactions in the block
uint256 TraverseAndExtract(int height, size_t pos, size_t &nBitsUsed, size_t &nHashUsed, std::vector< uint256 > &vMatch, std::vector< size_t > &vnIndex)
Recursive function that traverses tree nodes, consuming the bits and hashes produced by TraverseAndBu...
size_t CalcTreeWidth(int height) const
Helper function to efficiently calculate the number of nodes at given height in the merkle tree.
std::vector< bool > vBits
node-is-parent-of-matched-txid bits
bool fBad
flag set when encountering invalid data
uint32_t GetNumTransactions() const
Get number of transactions the merkle proof is indicating for cross-reference with local blockchain k...
uint256 ExtractMatches(std::vector< uint256 > &vMatch, std::vector< size_t > &vnIndex)
Extract the matching txid's represented by this partial merkle tree and their respective indices with...
std::vector< uint256 > vHash
txids and internal hashes
SERIALIZE_METHODS(CPartialMerkleTree, obj)
uint256 CalcHash(int height, size_t pos, const std::vector< uint256 > &vTxid)
Calculate the hash of a node in the merkle tree (at leaf level: the txid's themselves)
void TraverseAndBuild(int height, size_t pos, const std::vector< uint256 > &vTxid, const std::vector< bool > &vMatch)
Recursive function that traverses tree nodes, storing the data as bits and hashes.
std::vector< uint8_t > BitsToBytes(const std::vector< bool > &bits)
std::vector< bool > BytesToBits(const std::vector< uint8_t > &bytes)
#define SER_WRITE(obj, code)
#define SER_READ(obj, code)