summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Guidarelli <ben.guidarelli@gmail.com>2021-12-10 11:31:49 -0500
committerGitHub <noreply@github.com>2021-12-10 11:31:49 -0500
commitb2ca02fe56e9fc350a3a1d8ff281c8833ca6a284 (patch)
tree43a52e433ac71c84b3e6a503a592eba9ba83c468
parent493c2ea67bbcae6e3c399b257069341e7b7cd040 (diff)
enumerate conditions that might cause this fetchAndWrite to return false (#3301)
## Summary The fetchAndWrite function contains some complex logic to ultimately determine if we should continue trying to catch up. The conditions that might cause it to return false should be more explicitly enumerated. ## Test Plan Just comments
-rw-r--r--catchup/service.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/catchup/service.go b/catchup/service.go
index de4a52a94..ff3df3609 100644
--- a/catchup/service.go
+++ b/catchup/service.go
@@ -195,7 +195,11 @@ func (s *Service) innerFetch(r basics.Round, peer network.Peer) (blk *bookkeepin
}
// fetchAndWrite fetches a block, checks the cert, and writes it to the ledger. Cert checking and ledger writing both wait for the ledger to advance if necessary.
-// Returns false if we couldn't fetch or write (i.e., if we failed even after a given number of retries or if we were told to abort.)
+// Returns false if we should stop trying to catch up. This may occur for several reasons:
+// - If the context is canceled (e.g. if the node is shutting down)
+// - If we couldn't fetch the block (e.g. if there are no peers available or we've reached the catchupRetryLimit)
+// - If the block is already in the ledger (e.g. if agreement service has already written it)
+// - If the retrieval of the previous block was unsuccessful
func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool, lookbackComplete chan bool, peerSelector *peerSelector) bool {
i := 0
hasLookback := false