7 #ifndef PIVX_MERKLEBLOCK_H
8 #define PIVX_MERKLEBLOCK_H
18 std::vector<unsigned char>
BitsToBytes(
const std::vector<bool>& bits);
19 std::vector<bool>
BytesToBits(
const std::vector<unsigned char>& bytes);
77 uint256 CalcHash(
int height,
unsigned int pos,
const std::vector<uint256>& vTxid);
80 void TraverseAndBuild(
int height,
unsigned int pos,
const std::vector<uint256>& vTxid,
const std::vector<bool>& vMatch);
86 uint256 TraverseAndExtract(
int height,
unsigned int pos,
unsigned int& nBitsUsed,
unsigned int& nHashUsed, std::vector<uint256>& vMatch);
93 std::vector<unsigned char> bytes;
101 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...
CMerkleBlock(const CBlock &block, const std::set< uint256 > &txids)
std::vector< std::pair< unsigned int, uint256 > > vMatchedTxn
Public only for unit testing and relay testing (not relayed).
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)
extract the matching txid's represented by this partial merkle tree.
uint256 TraverseAndExtract(int height, unsigned int pos, unsigned int &nBitsUsed, unsigned int &nHashUsed, std::vector< uint256 > &vMatch)
recursive function that traverses tree nodes, consuming the bits and hashes produced by TraverseAndBu...
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
SERIALIZE_METHODS(CPartialMerkleTree, obj)
std::vector< bool > BytesToBits(const std::vector< unsigned char > &bytes)
std::vector< unsigned char > BitsToBytes(const std::vector< bool > &bits)
#define SER_WRITE(obj, code)
#define SER_READ(obj, code)