48 while (
hashes.size() > 1) {
50 for (
size_t pos = 0; pos + 1 <
hashes.size(); pos += 2) {
68 std::vector<uint256> leaves;
69 leaves.reserve((block.
vtx.size() + 1) & ~1ULL);
70 for (
size_t s = 0; s < block.
vtx.size(); s++) {
71 leaves.push_back(block.
vtx[s]->GetHash().ToUint256());
78 std::vector<uint256> leaves;
79 leaves.reserve((block.
vtx.size() + 1) & ~1ULL);
80 leaves.emplace_back();
81 for (
size_t s = 1; s < block.
vtx.size(); s++) {
82 leaves.push_back(block.
vtx[s]->GetWitnessHash().ToUint256());
92 if (leaves.size() == 0) {
106 while (
count < leaves.size()) {
114 for (level = 0; !(
count & ((
uint32_t{1}) << level)); level++) {
116 path.push_back(inner[level]);
121 h =
Hash(inner[level], h);
155 path.push_back(inner[level]);
160 h =
Hash(inner[level], h);
167 std::vector<uint256>
ret;
174 std::vector<uint256> leaves;
175 leaves.resize(block.
vtx.size());
176 for (
size_t s = 0; s < block.
vtx.size(); s++) {
177 leaves[s] = block.
vtx[s]->GetHash().ToUint256();
#define Assume(val)
Assume is the identity function.
std::vector< CTransactionRef > vtx
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
static std::vector< uint256 > ComputeMerklePath(const std::vector< uint256 > &leaves, uint32_t position)
static void MerkleComputation(const std::vector< uint256 > &leaves, uint32_t leaf_pos, std::vector< uint256 > &path)
std::vector< uint256 > TransactionMerklePath(const CBlock &block, uint32_t position)
Compute merkle path to the specified transaction.
uint256 BlockWitnessMerkleRoot(const CBlock &block)
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
void SHA256D64(unsigned char *out, const unsigned char *in, size_t blocks)
Compute multiple double-SHA256's of 64-byte blobs.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.