 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_MERKLEBLOCK_H
7 #define BITCOIN_MERKLEBLOCK_H
17 std::vector<unsigned char>
BitsToBytes(
const std::vector<bool>& bits);
18 std::vector<bool>
BytesToBits(
const std::vector<unsigned char>& bytes);
75 uint256 CalcHash(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid);
78 void TraverseAndBuild(
int height,
unsigned int pos,
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
84 uint256 TraverseAndExtract(
int height,
unsigned int pos,
unsigned int &nBitsUsed,
unsigned int &nHashUsed, std::vector<uint256> &vMatch, std::vector<unsigned int> &vnIndex);
91 std::vector<unsigned char> bytes;
99 CPartialMerkleTree(
const std::vector<uint256> &vTxid,
const std::vector<bool> &vMatch);
158 #endif // BITCOIN_MERKLEBLOCK_H
unsigned int GetNumTransactions() const
Get number of transactions the merkle proof is indicating for cross-reference with local blockchain k...
SERIALIZE_METHODS(CPartialMerkleTree, obj)
std::vector< bool > vBits
node-is-parent-of-matched-txid bits
Data structure that represents a partial merkle tree.
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.
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...
CBlockHeader header
Public only for unit testing.
CMerkleBlock(const CBlock &block, const std::set< uint256 > &txids)
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< unsigned char > BitsToBytes(const std::vector< bool > &bits)
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
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...
SERIALIZE_METHODS(CMerkleBlock, obj)
unsigned int nTransactions
the total number of transactions in the block
unsigned int CalcTreeWidth(int height) const
helper function to efficiently calculate the number of nodes at given height in the merkle tree
std::vector< std::pair< unsigned int, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed).
CMerkleBlock(const CBlock &block, CBloomFilter &filter)
Create from a CBlock, filtering transactions according to filter Note that this will call IsRelevantA...
#define SER_WRITE(obj, code)
#define SER_READ(obj, code)
std::vector< uint256 > vHash
txids and internal hashes
std::vector< bool > BytesToBits(const std::vector< unsigned char > &bytes)