@@ -475,14 +475,14 @@ func (m *Manager) applyTip(sp StoreScratchpad, index types.ChainIndex) error {
475475 return nil
476476}
477477
478- func (m * Manager ) reorgPath (sp StoreScratchpad , a , b types.ChainIndex , maxLen int ) (revert , apply []types.ChainIndex , err error ) {
478+ func (m * Manager ) reorgPath (ss StoreSnapshot , a , b types.ChainIndex , maxLen int ) (revert , apply []types.ChainIndex , err error ) {
479479 // helper function for "rewinding" to the parent index
480480 rewind := func (index * types.ChainIndex ) bool {
481481 if len (revert )+ len (apply ) > maxLen {
482482 err = fmt .Errorf ("reorg path is too long (-%d +%d, max %d)" , len (revert ), len (apply ), maxLen )
483483 return false
484484 }
485- bh , ok := sp .Header (index .ID )
485+ bh , ok := ss .Header (index .ID )
486486 if ! ok {
487487 err = fmt .Errorf ("%w %v" , ErrMissingBlock , * index )
488488 } else {
@@ -507,7 +507,7 @@ func (m *Manager) reorgPath(sp StoreScratchpad, a, b types.ChainIndex, maxLen in
507507
508508 // special case: if a is uninitialized, we're starting from genesis
509509 if a == (types.ChainIndex {}) {
510- a , _ = sp .BestIndex (0 )
510+ a , _ = ss .BestIndex (0 )
511511 apply = append (apply , a )
512512 }
513513
@@ -1283,10 +1283,10 @@ func (m *Manager) checkTxnSet(sp StoreScratchpad, txns []types.Transaction, v2tx
12831283 return allInPool , nil
12841284}
12851285
1286- func (m * Manager ) updateV2TransactionProofs (sp StoreScratchpad , txns []types.V2Transaction , from , to types.ChainIndex ) (updated []types.V2Transaction , err error ) {
1286+ func (m * Manager ) updateV2TransactionProofs (ss StoreSnapshot , txns []types.V2Transaction , from , to types.ChainIndex ) (updated []types.V2Transaction , err error ) {
12871287 // first validate the transaction set against its claimed basis; attempting
12881288 // to update an invalid proof can cause a panic
1289- basisState , ok := sp .State (from .ID )
1289+ basisState , ok := ss .State (from .ID )
12901290 if ! ok {
12911291 return nil , fmt .Errorf ("couldn't find state for basis %v" , from )
12921292 }
@@ -1296,7 +1296,7 @@ func (m *Manager) updateV2TransactionProofs(sp StoreScratchpad, txns []types.V2T
12961296 }
12971297 }
12981298
1299- revert , apply , err := m .reorgPath (sp , from , to , 144 )
1299+ revert , apply , err := m .reorgPath (ss , from , to , 144 )
13001300 if err != nil {
13011301 return nil , fmt .Errorf ("couldn't determine reorg path from %v to %v: %w" , from , to , err )
13021302 }
@@ -1307,7 +1307,7 @@ func (m *Manager) updateV2TransactionProofs(sp StoreScratchpad, txns []types.V2T
13071307 updated = append (updated , txn .DeepCopy ())
13081308 }
13091309 for _ , index := range revert {
1310- b , bs , cs , ok := blockAndParent (sp , index .ID )
1310+ b , bs , cs , ok := blockAndParent (ss , index .ID )
13111311 if ! ok {
13121312 return nil , fmt .Errorf ("missing reverted block at index %v" , index )
13131313 } else if bs == nil {
@@ -1324,15 +1324,15 @@ func (m *Manager) updateV2TransactionProofs(sp StoreScratchpad, txns []types.V2T
13241324 }
13251325
13261326 for _ , index := range apply {
1327- b , bs , cs , ok := blockAndParent (sp , index .ID )
1327+ b , bs , cs , ok := blockAndParent (ss , index .ID )
13281328 if ! ok {
13291329 return nil , fmt .Errorf ("missing applied block at index %v" , index )
13301330 } else if bs == nil {
13311331 return nil , fmt .Errorf ("missing applied block supplement at index %v" , index )
13321332 } else if err := m .overwriteExpirations (b , bs ); err != nil {
13331333 return nil , fmt .Errorf ("failed to overwrite expirations for block %v: %w" , index , err )
13341334 }
1335- ancestorTimestamp , _ := sp .AncestorTimestamp (b .ParentID )
1335+ ancestorTimestamp , _ := ss .AncestorTimestamp (b .ParentID )
13361336 cs , cau := consensus .ApplyBlock (cs , b , * bs , ancestorTimestamp )
13371337
13381338 // get the transactions that were confirmed in this block
@@ -1452,9 +1452,9 @@ func (m *Manager) UpdateV2TransactionSet(txns []types.V2Transaction, from, to ty
14521452 if from == to {
14531453 return txns , nil
14541454 }
1455- sp , unlock := m .scratchpad ()
1455+ ss , unlock := m .snapshot ()
14561456 defer unlock ()
1457- return m .updateV2TransactionProofs (sp , txns , from , to )
1457+ return m .updateV2TransactionProofs (ss , txns , from , to )
14581458}
14591459
14601460// AddV2PoolTransactions validates a transaction set and adds it to the txpool.
0 commit comments