From 38ae2e7cf9b978a1121f844823d7b13a4494a786 Mon Sep 17 00:00:00 2001 From: lukechampine Date: Sun, 31 Dec 2023 00:30:54 -0500 Subject: [PATCH] consensus: Set Spent flag in RevertUpdate.ForEachTreeNode --- consensus/merkle.go | 3 --- consensus/update.go | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/consensus/merkle.go b/consensus/merkle.go index 6a1a2c5a..d9c3a1aa 100644 --- a/consensus/merkle.go +++ b/consensus/merkle.go @@ -359,9 +359,6 @@ func (acc *ElementAccumulator) applyBlock(updated, added []elementLeaf) (eau ele // elements. All of the elements will be marked unspent. The accumulator itself // is not modified. func (acc *ElementAccumulator) revertBlock(updated, added []elementLeaf) (eru elementRevertUpdate) { - for i := range updated { - updated[i].Spent = false // reverting a block can never cause an element to become spent - } eru.updated = updateLeaves(updated) eru.numLeaves = acc.NumLeaves for i := range added { diff --git a/consensus/update.go b/consensus/update.go index dc09a360..25f8aa18 100644 --- a/consensus/update.go +++ b/consensus/update.go @@ -800,6 +800,7 @@ func (ru RevertUpdate) ForEachV2FileContractElement(fn func(fce types.V2FileCont func (ru RevertUpdate) ForEachTreeNode(fn func(row, col uint64, h types.Hash256)) { seen := make(map[[2]uint64]bool) ru.ms.forEachElementLeaf(func(el elementLeaf) { + el.Spent = false // reverting a block can never cause an element to become spent row, col := uint64(0), el.LeafIndex h := el.hash() fn(row, col, h) @@ -831,6 +832,7 @@ func RevertBlock(s State, b types.Block, bs V1BlockSupplement) RevertUpdate { // compute updated elements var updated, added []elementLeaf ms.forEachElementLeaf(func(el elementLeaf) { + el.Spent = false // reverting a block can never cause an element to become spent if el.MerkleProof != nil { updated = append(updated, el) } else {