Skip to content

Commit 59e3d84

Browse files
committed
Fix: stop the completed catchup service
1 parent b6cbbf3 commit 59e3d84

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

catchup/service.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@ func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool,
241241

242242
if err != nil {
243243
if err == errLedgerAlreadyHasBlock {
244-
// ledger already has the block, no need to request this block from anyone.
245-
return true
244+
// ledger already has the block, no need to request this block.
245+
// only the agreement could have added this block into the ledger, catchup is complete
246+
s.log.Infof("fetchAndWrite(%d): the block is already in the ledger. The catchup is complete", r)
247+
return false
246248
}
247249
s.log.Debugf("fetchAndWrite(%v): Could not fetch: %v (attempt %d)", r, err, i)
248250
peerSelector.rankPeer(psp, peerRankDownloadFailed)
@@ -353,8 +355,10 @@ func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool,
353355
s.log.Infof("fetchAndWrite(%d): no need to re-evaluate historical block", r)
354356
return true
355357
case ledgercore.BlockInLedgerError:
356-
s.log.Infof("fetchAndWrite(%d): block already in ledger", r)
357-
return true
358+
// the block was added to the ledger from elsewhere after fetching it here
359+
// only the agreement could have added this block into the ledger, catchup is complete
360+
s.log.Infof("fetchAndWrite(%d): after fetching the block, it is already in the ledger. The catchup is complete", r)
361+
return false
358362
case protocol.Error:
359363
if !s.protocolErrorLogged {
360364
logging.Base().Errorf("fetchAndWrite(%v): unrecoverable protocol error detected: %v", r, err)
@@ -387,7 +391,7 @@ func (s *Service) pipelineCallback(r basics.Round, thisFetchComplete chan bool,
387391
thisFetchComplete <- fetchResult
388392

389393
if !fetchResult {
390-
s.log.Infof("failed to fetch block %v", r)
394+
s.log.Infof("pipelineCallback(%d): did not fetch or write the block", r)
391395
return 0
392396
}
393397
return r

0 commit comments

Comments
 (0)