6#ifndef BITCOIN_MERKLEBLOCK_H
7#define BITCOIN_MERKLEBLOCK_H
18std::vector<unsigned char>
BitsToBytes(
const std::vector<bool>& bits);
19std::vector<bool>
BytesToBits(
const std::vector<unsigned char>& bytes);
76 uint256 CalcHash(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid);
79 void TraverseAndBuild(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
85 uint256 TraverseAndExtract(
int height,
unsigned int pos,
unsigned int &nBitsUsed,
unsigned int &nHashUsed, std::vector<uint256> &vMatch, std::vector<unsigned int> &vnIndex);
92 std::vector<unsigned char> bytes;
100 CPartialMerkleTree(
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
SERIALIZE_METHODS(CMerkleBlock, obj)
CBlockHeader header
Public only for unit testing.
CMerkleBlock(const CBlock &block, CBloomFilter &filter)
Create from a CBlock, filtering transactions according to filter Note that this will call IsRelevantA...
std::vector< std::pair< unsigned int, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed).
CMerkleBlock(const CBlock &block, const std::set< Txid > &txids)
Data structure that represents a partial merkle tree.
unsigned int nTransactions
the total number of transactions in the block
std::vector< bool > vBits
node-is-parent-of-matched-txid bits
bool fBad
flag set when encountering invalid data
uint256 ExtractMatches(std::vector< uint256 > &vMatch, std::vector< unsigned int > &vnIndex)
extract the matching txid's represented by this partial merkle tree and their respective indices with...
unsigned int GetNumTransactions() const
Get number of transactions the merkle proof is indicating for cross-reference with local blockchain k...
void TraverseAndBuild(int height, unsigned int pos, const std::vector< uint256 > &vTxid, const std::vector< bool > &vMatch)
recursive function that traverses tree nodes, storing the data as bits and hashes
uint256 CalcHash(int height, unsigned int pos, const std::vector< uint256 > &vTxid)
calculate the hash of a node in the merkle tree (at leaf level: the txid's themselves)
std::vector< uint256 > vHash
txids and internal hashes
uint256 TraverseAndExtract(int height, unsigned int pos, unsigned int &nBitsUsed, unsigned int &nHashUsed, std::vector< uint256 > &vMatch, std::vector< unsigned int > &vnIndex)
recursive function that traverses tree nodes, consuming the bits and hashes produced by TraverseAndBu...
SERIALIZE_METHODS(CPartialMerkleTree, obj)
unsigned int CalcTreeWidth(int height) const
helper function to efficiently calculate the number of nodes at given height in the merkle tree
std::vector< unsigned char > BitsToBytes(const std::vector< bool > &bits)
std::vector< bool > BytesToBits(const std::vector< unsigned char > &bytes)
#define SER_WRITE(obj, code)
#define SER_READ(obj, code)