mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/downloader: address comments
This commit is contained in:
parent
5b6571fe74
commit
eead5a20f8
2 changed files with 15 additions and 11 deletions
|
|
@ -50,7 +50,8 @@ func newBeaconBackfiller(dl *Downloader, success func()) backfiller {
|
|||
}
|
||||
|
||||
// suspend cancels any background downloader threads and returns the last header
|
||||
// that has been successfully backfilled.
|
||||
// that has been successfully backfilled (potentially in a previous run), or the
|
||||
// genesis.
|
||||
func (b *beaconBackfiller) suspend() *types.Header {
|
||||
// If no filling is running, don't waste cycles
|
||||
b.lock.Lock()
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ type backfiller interface {
|
|||
// on initial startup.
|
||||
//
|
||||
// The method should return the last block header that has been successfully
|
||||
// backfilled, or nil if the backfiller was not resumed.
|
||||
// backfilled (in the current or a previous run), falling back to the genesis.
|
||||
suspend() *types.Header
|
||||
|
||||
// resume requests the backfiller to start running fill or snap sync based on
|
||||
|
|
@ -382,14 +382,17 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) {
|
|||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
if filled := s.filler.suspend(); filled != nil {
|
||||
// If something was filled, try to delete stale sync helpers. If
|
||||
// unsuccessful, warn the user, but not much else we can do (it's
|
||||
// a programming error, just let users report an issue and don't
|
||||
// choke in the meantime).
|
||||
if err := s.cleanStales(filled); err != nil {
|
||||
log.Error("Failed to clean stale beacon headers", "err", err)
|
||||
}
|
||||
filled := s.filler.suspend()
|
||||
if filled == nil {
|
||||
log.Error("Latest filled block is not available")
|
||||
return
|
||||
}
|
||||
// If something was filled, try to delete stale sync helpers. If
|
||||
// unsuccessful, warn the user, but not much else we can do (it's
|
||||
// a programming error, just let users report an issue and don't
|
||||
// choke in the meantime).
|
||||
if err := s.cleanStales(filled); err != nil {
|
||||
log.Error("Failed to clean stale beacon headers", "err", err)
|
||||
}
|
||||
}()
|
||||
// Wait for the suspend to finish, consuming head events in the meantime
|
||||
|
|
@ -1138,7 +1141,7 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
|
|||
// The skeleton chain is partially consumed, set the new tail as filled+1.
|
||||
tail := rawdb.ReadSkeletonHeader(s.db, number+1)
|
||||
if tail.ParentHash != filled.Hash() {
|
||||
return fmt.Errorf("filled header is discontinuous with subchain: %d %s", number, filled.Hash())
|
||||
return fmt.Errorf("filled header is discontinuous with subchain: %d %s, please file an issue", number, filled.Hash())
|
||||
}
|
||||
start, end = s.progress.Subchains[0].Tail, number+1 // remove headers in [tail, filled]
|
||||
s.progress.Subchains[0].Tail = tail.Number.Uint64()
|
||||
|
|
|
|||
Loading…
Reference in a new issue