From a2d6b524830e114971864d6d2a9bcf2e62fc5d57 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Fri, 1 Jan 2021 20:36:27 -0500 Subject: [PATCH] In case requests to all seed nodes fail we take persisted and reported peers for requests. Before we added also the seed nodes which would delay connection to other nodes a lot. --- .../p2p/peers/getdata/RequestDataManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java index a8dc8ba89e5..5860e84045e 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java @@ -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()); } @@ -405,6 +405,18 @@ public void onFault(String errorMessage, @Nullable Connection connection) { // Utils /////////////////////////////////////////////////////////////////////////////////////////// + private void requestFromNonSeedNodePeers() { + List list = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getReportedPeers()), new ArrayList<>()); + List 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(() -> {