Skip to content

Commit

Permalink
catchpoints: check EnableCatchupFromArchiveServers for ledgerFetcher (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
ohill authored Oct 13, 2023
1 parent 4249027 commit d3df476
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions catchup/catchpointService.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (cs *CatchpointCatchupService) processStageLedgerDownload() (err error) {
}

// download balances file.
peerSelector := makePeerSelector(cs.net, []peerClass{{initialRank: peerRankInitialFirstPriority, peerClass: network.PeersPhonebookRelays}})
peerSelector := cs.makeCatchpointPeerSelector()
ledgerFetcher := makeLedgerFetcher(cs.net, cs.ledgerAccessor, cs.log, cs, cs.config)
attemptsCount := 0

Expand Down Expand Up @@ -796,15 +796,19 @@ func (cs *CatchpointCatchupService) updateBlockRetrievalStatistics(acquiredBlock
}

func (cs *CatchpointCatchupService) initDownloadPeerSelector() {
cs.blocksDownloadPeerSelector = cs.makeCatchpointPeerSelector()
}

func (cs *CatchpointCatchupService) makeCatchpointPeerSelector() *peerSelector {
if cs.config.EnableCatchupFromArchiveServers {
cs.blocksDownloadPeerSelector = makePeerSelector(
return makePeerSelector(
cs.net,
[]peerClass{
{initialRank: peerRankInitialFirstPriority, peerClass: network.PeersPhonebookArchivers},
{initialRank: peerRankInitialSecondPriority, peerClass: network.PeersPhonebookRelays},
})
} else {
cs.blocksDownloadPeerSelector = makePeerSelector(
return makePeerSelector(
cs.net,
[]peerClass{
{initialRank: peerRankInitialFirstPriority, peerClass: network.PeersPhonebookRelays},
Expand All @@ -820,7 +824,7 @@ func (cs *CatchpointCatchupService) checkLedgerDownload() error {
if err != nil {
return fmt.Errorf("failed to parse catchpoint label : %v", err)
}
peerSelector := makePeerSelector(cs.net, []peerClass{{initialRank: peerRankInitialFirstPriority, peerClass: network.PeersPhonebookRelays}})
peerSelector := cs.makeCatchpointPeerSelector()
ledgerFetcher := makeLedgerFetcher(cs.net, cs.ledgerAccessor, cs.log, cs, cs.config)
for i := 0; i < cs.config.CatchupLedgerDownloadRetryAttempts; i++ {
psp, peerError := peerSelector.getNextPeer()
Expand Down

0 comments on commit d3df476

Please sign in to comment.