6 #ifndef BITCOIN_MERKLEBLOCK_H
7 #define BITCOIN_MERKLEBLOCK_H
71 uint256 CalcHash(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid);
74 void TraverseAndBuild(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
80 uint256 TraverseAndExtract(
int height,
unsigned int pos,
unsigned int &nBitsUsed,
unsigned int &nHashUsed, std::vector<uint256> &vMatch, std::vector<unsigned int> &vnIndex);
87 template <
typename Stream,
typename Operation>
91 std::vector<unsigned char> vBytes;
92 if (ser_action.ForRead()) {
95 us.
vBits.resize(vBytes.size() * 8);
96 for (
unsigned int p = 0; p < us.
vBits.size(); p++)
97 us.
vBits[p] = (vBytes[p / 8] & (1 << (p % 8))) != 0;
100 vBytes.resize((
vBits.size()+7)/8);
101 for (
unsigned int p = 0; p <
vBits.size(); p++)
102 vBytes[p / 8] |=
vBits[p] << (p % 8);
108 CPartialMerkleTree(
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
150 template <
typename Stream,
typename Operation>
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.
CBlockHeader header
Public only for unit testing.
std::vector< std::pair< unsigned int, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed)
void SerializationOp(Stream &s, Operation ser_action)
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...
void SerializationOp(Stream &s, Operation ser_action)
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)
unsigned int CalcTreeWidth(int height)
helper function to efficiently calculate the number of nodes at given height in the merkle tree
std::vector< uint256 > vHash
txids and internal hashes
ADD_SERIALIZE_METHODS
serialization implementation
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...