Skip to content

Commit

Permalink
Merge pull request #5041 from chimp1984/request-only-not-seeds-if-no-…
Browse files Browse the repository at this point in the history
…seed-available

Request only non-seed nodes if no seed nodes are available
  • Loading branch information
sqrrm authored Jan 4, 2021
2 parents bf7a528 + a2d6b52 commit 4da1bb0
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public void onFault(String errorMessage, @Nullable Connection connection) {
listener.onNoPeersAvailable();
}

restart();
requestFromNonSeedNodePeers();
} else {
log.info("We could not connect to seed node {} but we have other connection attempts open.", nodeAddress.getFullAddress());
}
Expand Down Expand Up @@ -405,6 +405,18 @@ public void onFault(String errorMessage, @Nullable Connection connection) {
// Utils
///////////////////////////////////////////////////////////////////////////////////////////

private void requestFromNonSeedNodePeers() {
List<NodeAddress> list = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getReportedPeers()), new ArrayList<>());
List<NodeAddress> filteredPersistedPeers = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getPersistedPeers()), list);
list.addAll(filteredPersistedPeers);

if (!list.isEmpty()) {
NodeAddress nextCandidate = list.get(0);
list.remove(nextCandidate);
requestData(nextCandidate, list);
}
}

private void restart() {
if (retryTimer == null) {
retryTimer = UserThread.runAfter(() -> {
Expand Down

0 comments on commit 4da1bb0

Please sign in to comment.