eth: reset skeleton after chain rewinded

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-06-26 23:50:57 +08:00
parent 16f50285b7
commit 896113e436
2 changed files with 8 additions and 0 deletions

View file

@ -63,6 +63,7 @@ func (b *EthAPIBackend) CurrentBlock() *types.Header {
func (b *EthAPIBackend) SetHead(number uint64) { func (b *EthAPIBackend) SetHead(number uint64) {
b.eth.handler.downloader.Cancel() b.eth.handler.downloader.Cancel()
b.eth.handler.downloader.ResetSkeleton()
b.eth.blockchain.SetHead(number) b.eth.blockchain.SetHead(number)
} }

View file

@ -662,6 +662,13 @@ func (d *Downloader) Cancel() {
d.blockchain.InterruptInsert(false) d.blockchain.InterruptInsert(false)
} }
// ResetSkeleton terminates the skeleton syncer and reinitializes it.
func (d *Downloader) ResetSkeleton() {
d.skeleton.Terminate()
rawdb.DeleteSkeletonSyncStatus(d.stateDB)
d.skeleton = newSkeleton(d.stateDB, d.peers, d.dropPeer, d.skeleton.filler)
}
// Terminate interrupts the downloader, canceling all pending operations. // Terminate interrupts the downloader, canceling all pending operations.
// The downloader cannot be reused after calling Terminate. // The downloader cannot be reused after calling Terminate.
func (d *Downloader) Terminate() { func (d *Downloader) Terminate() {