From c62be529b1bdcdf97e4e2ac1125b85d8aca22c52 Mon Sep 17 00:00:00 2001 From: lukechampine Date: Wed, 26 Jun 2024 16:04:57 -0400 Subject: [PATCH] chain: Workaround unexported consensus constant --- chain/manager.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chain/manager.go b/chain/manager.go index c7f4559..02cc94d 100644 --- a/chain/manager.go +++ b/chain/manager.go @@ -610,11 +610,14 @@ func (m *Manager) computeParentMap() map[types.Hash256]int { return m.txpool.parentMap } +// bit of a hack +var ephemeralLeafIndex = consensus.UnassignedStateElement(types.Hash256{}).LeafIndex + func updateTxnProofs(txn *types.V2Transaction, updateElementProof func(*types.StateElement), numLeaves uint64) (valid bool) { valid = true updateProof := func(e *types.StateElement) { valid = valid && e.LeafIndex < numLeaves - if !valid || e.LeafIndex == types.EphemeralLeafIndex { + if !valid || e.LeafIndex == ephemeralLeafIndex { return } updateElementProof(e) @@ -641,7 +644,7 @@ func (m *Manager) revertPoolUpdate(cru consensus.RevertUpdate, cs consensus.Stat // restore ephemeral elements, if necessary var uncreated map[types.Hash256]bool replaceEphemeral := func(e *types.StateElement) { - if e.LeafIndex != types.EphemeralLeafIndex { + if e.LeafIndex != ephemeralLeafIndex { return } else if uncreated == nil { uncreated = make(map[types.Hash256]bool) @@ -667,7 +670,7 @@ func (m *Manager) revertPoolUpdate(cru consensus.RevertUpdate, cs consensus.Stat }) } if uncreated[e.ID] { - *e = types.StateElement{ID: e.ID, LeafIndex: types.EphemeralLeafIndex} + *e = consensus.UnassignedStateElement(e.ID) } } for _, txn := range m.txpool.v2txns { @@ -698,7 +701,7 @@ func (m *Manager) applyPoolUpdate(cau consensus.ApplyUpdate, cs consensus.State) // replace ephemeral elements, if necessary var newElements map[types.Hash256]types.StateElement replaceEphemeral := func(e *types.StateElement) { - if e.LeafIndex != types.EphemeralLeafIndex { + if e.LeafIndex != ephemeralLeafIndex { return } else if newElements == nil { newElements = make(map[types.Hash256]types.StateElement)