mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
TxLookup unwind: Remove entries for blocks between unwindPoint+1 and stage.BlockNumber (#723)
This commit is contained in:
parent
9881a2ccb3
commit
2689b35da9
@ -307,7 +307,8 @@ func stage9(ctx context.Context) error {
|
||||
|
||||
if unwind > 0 {
|
||||
u := &stagedsync.UnwindState{Stage: stages.TxLookup, UnwindPoint: stage9.BlockNumber - unwind}
|
||||
return stagedsync.UnwindTxLookup(u, db, "", ch)
|
||||
s := progress(db, stages.TxLookup)
|
||||
return stagedsync.UnwindTxLookup(u, s, db, "", ch)
|
||||
}
|
||||
|
||||
return stagedsync.SpawnTxLookup(stage9, db, "", ch)
|
||||
|
@ -120,7 +120,8 @@ func syncBySmallSteps(ctx context.Context, chaindata string) error {
|
||||
to := execStage.BlockNumber - unwind
|
||||
{
|
||||
u := &stagedsync.UnwindState{Stage: stages.TxLookup, UnwindPoint: to}
|
||||
if err = stagedsync.UnwindTxLookup(u, db, "", ch); err != nil {
|
||||
stage9 := progress(db, stages.TxLookup)
|
||||
if err = stagedsync.UnwindTxLookup(u, stage9, db, "", ch); err != nil {
|
||||
return fmt.Errorf("unwindTxLookup: %w", err)
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,16 @@ func TxLookupTransform(db ethdb.Database, startKey, endKey []byte, quitCh <-chan
|
||||
})
|
||||
}
|
||||
|
||||
func UnwindTxLookup(u *UnwindState, db ethdb.Database, datadir string, quitCh <-chan struct{}) error {
|
||||
func UnwindTxLookup(u *UnwindState, s *StageState, db ethdb.Database, datadir string, quitCh <-chan struct{}) error {
|
||||
collector := etl.NewCollector(datadir, etl.NewSortableBuffer(etl.BufferOptimalSize))
|
||||
// Remove lookup entries for all blocks above unwindPoint
|
||||
if err := db.Walk(dbutils.BlockBodyPrefix, dbutils.EncodeBlockNumber(u.UnwindPoint+1), 8*8, func(k, v []byte) (b bool, e error) {
|
||||
|
||||
// Remove lookup entries for blocks between unwindPoint+1 and stage.BlockNumber
|
||||
if err := db.Walk(dbutils.BlockBodyPrefix, dbutils.EncodeBlockNumber(u.UnwindPoint+1), 0, func(k, v []byte) (b bool, e error) {
|
||||
blockNumber := binary.BigEndian.Uint64(k[:8])
|
||||
if blockNumber > s.BlockNumber {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if err := common.Stopped(quitCh); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func PrepareStagedSync(
|
||||
return SpawnTxLookup(s, stateDB, datadir, quitCh)
|
||||
},
|
||||
UnwindFunc: func(u *UnwindState, s *StageState) error {
|
||||
return UnwindTxLookup(u, stateDB, datadir, quitCh)
|
||||
return UnwindTxLookup(u, s, stateDB, datadir, quitCh)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user