19 vector<uint256> vHashes;
21 vMatch.reserve(block.
vtx.size());
22 vHashes.reserve(block.
vtx.size());
24 for (
unsigned int i = 0; i < block.
vtx.size(); i++)
29 vMatch.push_back(
true);
30 vMatchedTxn.push_back(make_pair(i, hash));
33 vMatch.push_back(
false);
34 vHashes.push_back(hash);
45 vector<uint256> vHashes;
47 vMatch.reserve(block.
vtx.size());
48 vHashes.reserve(block.
vtx.size());
50 for (
unsigned int i = 0; i < block.
vtx.size(); i++)
53 if (txids.count(hash))
54 vMatch.push_back(
true);
56 vMatch.push_back(
false);
57 vHashes.push_back(hash);
69 uint256 left = CalcHash(height-1, pos*2, vTxid), right;
71 if (pos*2+1 < CalcTreeWidth(height-1))
72 right = CalcHash(height-1, pos*2+1, vTxid);
82 bool fParentOfMatch =
false;
83 for (
unsigned int p = pos << height;
p < (pos+1) << height &&
p < nTransactions;
p++)
84 fParentOfMatch |= vMatch[
p];
86 vBits.push_back(fParentOfMatch);
87 if (height==0 || !fParentOfMatch) {
89 vHash.push_back(CalcHash(height, pos, vTxid));
92 TraverseAndBuild(height-1, pos*2, vTxid, vMatch);
93 if (pos*2+1 < CalcTreeWidth(height-1))
94 TraverseAndBuild(height-1, pos*2+1, vTxid, vMatch);
99 if (nBitsUsed >= vBits.size()) {
104 bool fParentOfMatch = vBits[nBitsUsed++];
105 if (height==0 || !fParentOfMatch) {
107 if (nHashUsed >= vHash.size()) {
112 const uint256 &hash = vHash[nHashUsed++];
113 if (height==0 && fParentOfMatch)
114 vMatch.push_back(hash);
118 uint256 left = TraverseAndExtract(height-1, pos*2, nBitsUsed, nHashUsed, vMatch), right;
119 if (pos*2+1 < CalcTreeWidth(height-1)) {
120 right = TraverseAndExtract(height-1, pos*2+1, nBitsUsed, nHashUsed, vMatch);
169 unsigned int nBitsUsed = 0, nHashUsed = 0;
175 if ((nBitsUsed+7)/8 != (
vBits.size()+7)/8)
178 if (nHashUsed !=
vHash.size())
180 return hashMerkleRoot;
unsigned int MaxBlockSize(bool fDIP0001Active)
uint256 ExtractMatches(std::vector< uint256 > &vMatch)
std::vector< CTransaction > vtx
unsigned int CalcTreeWidth(int height)
uint256 Hash(const T1 pbegin, const T1 pend)
unsigned int nTransactions
std::vector< uint256 > vHash
void TraverseAndBuild(int height, unsigned int pos, const std::vector< uint256 > &vTxid, const std::vector< bool > &vMatch)
uint256 TraverseAndExtract(int height, unsigned int pos, unsigned int &nBitsUsed, unsigned int &nHashUsed, std::vector< uint256 > &vMatch)
std::vector< bool > vBits
bool IsRelevantAndUpdate(const CTransaction &tx)
Also adds any outputs which match the filter to the filter (to match their spending txes) ...
CBlockHeader GetBlockHeader() const
uint256 CalcHash(int height, unsigned int pos, const std::vector< uint256 > &vTxid)