6 #ifndef FABCOIN_MERKLEBLOCK_H 7 #define FABCOIN_MERKLEBLOCK_H 67 return (nTransactions+(1 << height)-1) >> height;
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);
152 template <
typename Stream,
typename Operation>
159 #endif // FABCOIN_MERKLEBLOCK_H CBlockHeader header
Public only for unit testing.
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 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 ...
void SerializationOp(Stream &s, Operation ser_action)
unsigned int nTransactions
the total number of transactions in the block
bool fBad
flag set when encountering invalid data
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Data structure that represents a partial merkle tree.
std::vector< uint256 > vHash
txids and internal hashes
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
unsigned int CalcTreeWidth(int height)
helper function to efficiently calculate the number of nodes at given height in the merkle tree ...
ADD_SERIALIZE_METHODS
serialization implementation
std::vector< bool > vBits
node-is-parent-of-matched-txid bits
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...
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)
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) ...