42 static void MerkleComputation(
const std::vector<uint256>& leaves,
uint256* proot,
bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {
43 if (pbranch) pbranch->clear();
44 if (leaves.size() == 0) {
45 if (pmutated) *pmutated =
false;
61 while (
count < leaves.size()) {
63 bool matchh =
count == branchpos;
72 pbranch->push_back(inner[
level]);
73 }
else if (matchlevel ==
level) {
74 pbranch->push_back(h);
78 mutated |= (inner[
level] == h);
97 bool matchh = matchlevel ==
level;
102 if (pbranch && matchh) {
103 pbranch->push_back(h);
114 pbranch->push_back(inner[
level]);
115 }
else if (matchlevel ==
level) {
116 pbranch->push_back(h);
125 if (pmutated) *pmutated = mutated;
126 if (proot) *proot = h;
136 std::vector<uint256> ret;
143 for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) {
156 std::vector<uint256> leaves;
157 leaves.resize(block.
vtx.size());
158 for (
size_t s = 0; s < block.
vtx.size(); s++) {
159 leaves[s] = block.
vtx[s].GetHash();
166 std::vector<uint256> leaves;
167 leaves.resize(block.
vtx.size());
168 for (
size_t s = 0; s < block.
vtx.size(); s++) {
169 leaves[s] = block.
vtx[s].GetHash();
std::vector< uint256 > BlockMerkleBranch(const CBlock &block, uint32_t position)
std::vector< uint256 > ComputeMerkleBranch(const std::vector< uint256 > &leaves, uint32_t position)
uint256 ComputeMerkleRootFromBranch(const uint256 &leaf, const std::vector< uint256 > &vMerkleBranch, uint32_t nIndex)
uint256 ComputeMerkleRoot(const std::vector< uint256 > &leaves, bool *mutated)
std::vector< CTransaction > vtx
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
uint256 Hash(const T1 pbegin, const T1 pend)
static void MerkleComputation(const std::vector< uint256 > &leaves, uint256 *proot, bool *pmutated, uint32_t branchpos, std::vector< uint256 > *pbranch)
CHash256 & Write(const unsigned char *data, size_t len)