StratisBitcoinFullNode
StratisBitcoinFullNode copied to clipboard
BlockMerkleRootRule - clarify leaves maximum
Hi,
I've been reading BlockMerkleRootRule.cs
and I have encountered the following line: https://github.com/stratisproject/StratisBitcoinFullNode/blob/master/src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/BlockMerkleRootRule.cs#L73 containing:
/// <remarks>This implements a constant-space merkle root/path calculator, limited to 2^32 leaves.</remarks>
The remark is misleading because leaves
input parameter of the function:
public static uint256 ComputeMerkleRoot(List<uint256> leaves, out bool mutated)
is limited to Int32.MaxValue
elements which is actually lower, i.e. 2^31 - 1. So the implementation can handle rather Int32.MaxValue
leaves and not 2^32 leaves.
I think this is mostly correct, but 0
can be a leaf too. So the maximum is Int32.MaxValue + 1
= 2^31
.