hash: introduce memory-optimized merkle root hash calculation routine
NewMerkleTree is a memory hog, we can do better than that: BenchmarkMerkle/NewMerkleTree-8 13 88434670 ns/op 20828207 B/op 300035 allocs/op BenchmarkMerkle/CalcMerkleRoot-8 15 69264150 ns/op 0 B/op 0 allocs/op
This commit is contained in:
parent
3f27cf5901
commit
d52e79668b
9 changed files with 83 additions and 33 deletions
|
@ -111,11 +111,11 @@ func TestHashBlockEqualsHashHeader(t *testing.T) {
|
|||
func TestBlockVerify(t *testing.T) {
|
||||
block := newDumbBlock()
|
||||
assert.NotNil(t, block.Verify())
|
||||
assert.Nil(t, block.RebuildMerkleRoot())
|
||||
block.RebuildMerkleRoot()
|
||||
assert.Nil(t, block.Verify())
|
||||
|
||||
block.Transactions = []*transaction.Transaction{}
|
||||
assert.NoError(t, block.RebuildMerkleRoot())
|
||||
block.RebuildMerkleRoot()
|
||||
assert.Nil(t, block.Verify())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue