Skip to content

Commit efad795

Browse files
Merge pull request ethereum#27 from karalabe/merge-interop-spec-sync7
eth/downloader: restart the downloader after completion on new head
2 parents 0b0427d + e90ede6 commit efad795

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

eth/downloader/beaconsync.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ func (b *beaconBackfiller) suspend() {
5454
// resume starts the downloader threads for backfilling state and chain data.
5555
func (b *beaconBackfiller) resume() {
5656
b.lock.Lock()
57+
if b.filling {
58+
// If a previous filling cycle is still running, just ignore this start
59+
// request. // TODO(karalabe): We should make this channel driven
60+
b.lock.Unlock()
61+
return
62+
}
5763
b.filling = true
5864
mode := b.syncMode
5965
b.lock.Unlock()

eth/downloader/downloader.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,6 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int, beaconMode bool)
12961296
}
12971297
d.pivotLock.RUnlock()
12981298

1299-
fmt.Println(pivot)
1300-
13011299
frequency := fsHeaderCheckFrequency
13021300
if chunk[len(chunk)-1].Number.Uint64()+uint64(fsHeaderForceVerify) > pivot {
13031301
frequency = 1

eth/downloader/skeleton.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ func (s *skeleton) Terminate() error {
294294
// This method does not block, rather it just waits until the syncer receives the
295295
// fed header. What the syncer does with it is the syncer's problem.
296296
func (s *skeleton) Sync(head *types.Header) error {
297+
log.Trace("New skeleton head announced", "number", head.Number, "hash", head.Hash())
297298
select {
298299
case s.headEvents <- head:
299300
return nil
@@ -393,6 +394,12 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) {
393394
if reorged := s.processNewHead(head); reorged {
394395
return head, errSyncReorged
395396
}
397+
// New head was integrated into the skeleton chain. If the backfiller
398+
// is still running, it will pick it up. If it already terminated,
399+
// a new cycle needs to be spun up.
400+
if s.scratchHead == 0 {
401+
s.filler.resume()
402+
}
396403

397404
case req := <-requestFails:
398405
s.revertRequest(req)

0 commit comments

Comments
 (0)