Switch blocks to a constant-space Merkle root/branch algorithm.
This switches the Merkle tree logic for blocks to one that runs in constant (small) space. The old code is moved to tests, and a new test is added that for various combinations of block sizes, transaction positions to compute a branch for, and mutations: * Verifies that the old code and new code agree for the Merkle root. * Verifies that the old code and new code agree for the Merkle branch. * Verifies that the computed Merkle branch is valid. * Verifies that mutations don't change the Merkle root. * Verifies that mutations are correctly detected.
This commit is contained in:
@@ -118,12 +118,6 @@ public:
|
||||
return block;
|
||||
}
|
||||
|
||||
// Build the merkle tree for this block and return the merkle root.
|
||||
// If non-NULL, *mutated is set to whether mutation was detected in the merkle
|
||||
// tree (a duplication of transactions in the block leading to an identical
|
||||
// merkle root).
|
||||
uint256 ComputeMerkleRoot(bool* mutated = NULL) const;
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user