mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Remove check for not empty seednodes (can be empty in some cases)
This commit is contained in:
parent
e7967cc0e1
commit
605cf27eaf
@ -93,6 +93,7 @@ public class PeerManager implements ConnectionListener {
|
||||
public PeerManager(NetworkNode networkNode, Set<NodeAddress> seedNodeAddresses, File storageDir, Clock clock) {
|
||||
this.networkNode = networkNode;
|
||||
this.clock = clock;
|
||||
// seedNodeAddresses can be empty (in case there is only 1 seed node, the seed node starting up has no other seed nodes)
|
||||
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||
networkNode.addConnectionListener(this);
|
||||
dbStorage = new Storage<>(storageDir);
|
||||
|
@ -69,10 +69,10 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||
this.networkNode = networkNode;
|
||||
this.dataStorage = dataStorage;
|
||||
this.peerManager = peerManager;
|
||||
// seedNodeAddresses can be empty (in case there is only 1 seed node, the seed node starting up has no other seed nodes)
|
||||
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||
this.listener = listener;
|
||||
|
||||
checkArgument(!seedNodeAddresses.isEmpty(), "seedNodeAddresses must not be empty.");
|
||||
networkNode.addMessageListener(this);
|
||||
peerManager.addListener(this);
|
||||
}
|
||||
@ -94,10 +94,12 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||
public void requestPreliminaryData() {
|
||||
Log.traceCall();
|
||||
ArrayList<NodeAddress> nodeAddresses = new ArrayList<>(seedNodeAddresses);
|
||||
Collections.shuffle(nodeAddresses);
|
||||
NodeAddress nextCandidate = nodeAddresses.get(0);
|
||||
nodeAddresses.remove(nextCandidate);
|
||||
requestData(nextCandidate, nodeAddresses);
|
||||
if (!nodeAddresses.isEmpty()) {
|
||||
Collections.shuffle(nodeAddresses);
|
||||
NodeAddress nextCandidate = nodeAddresses.get(0);
|
||||
nodeAddresses.remove(nextCandidate);
|
||||
requestData(nextCandidate, nodeAddresses);
|
||||
}
|
||||
}
|
||||
|
||||
public void requestUpdateData() {
|
||||
@ -105,10 +107,12 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||
checkArgument(nodeAddressOfPreliminaryDataRequest.isPresent(), "seedNodeOfPreliminaryDataRequest must be present");
|
||||
dataUpdateRequested = true;
|
||||
List<NodeAddress> remainingNodeAddresses = new ArrayList<>(seedNodeAddresses);
|
||||
Collections.shuffle(remainingNodeAddresses);
|
||||
NodeAddress candidate = nodeAddressOfPreliminaryDataRequest.get();
|
||||
remainingNodeAddresses.remove(candidate);
|
||||
requestData(candidate, remainingNodeAddresses);
|
||||
if (!remainingNodeAddresses.isEmpty()) {
|
||||
Collections.shuffle(remainingNodeAddresses);
|
||||
NodeAddress candidate = nodeAddressOfPreliminaryDataRequest.get();
|
||||
remainingNodeAddresses.remove(candidate);
|
||||
requestData(candidate, remainingNodeAddresses);
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<NodeAddress> getNodeAddressOfPreliminaryDataRequest() {
|
||||
@ -315,10 +319,11 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||
List<NodeAddress> filteredPersistedPeers = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getPersistedPeers()), list);
|
||||
list.addAll(filteredPersistedPeers);
|
||||
|
||||
checkArgument(!list.isEmpty(), "seedNodeAddresses must not be empty.");
|
||||
NodeAddress nextCandidate = list.get(0);
|
||||
list.remove(nextCandidate);
|
||||
requestData(nextCandidate, list);
|
||||
if (!list.isEmpty()) {
|
||||
NodeAddress nextCandidate = list.get(0);
|
||||
list.remove(nextCandidate);
|
||||
requestData(nextCandidate, list);
|
||||
}
|
||||
},
|
||||
RETRY_DELAY_SEC);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener {
|
||||
@ -41,7 +40,7 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener,
|
||||
public PeerExchangeManager(NetworkNode networkNode, PeerManager peerManager, Set<NodeAddress> seedNodeAddresses) {
|
||||
this.networkNode = networkNode;
|
||||
this.peerManager = peerManager;
|
||||
checkArgument(!seedNodeAddresses.isEmpty(), "seedNodeAddresses must not be empty");
|
||||
// seedNodeAddresses can be empty (in case there is only 1 seed node, the seed node starting up has no other seed nodes)
|
||||
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||
|
||||
networkNode.addMessageListener(this);
|
||||
|
@ -32,15 +32,15 @@ public class SeedNodesRepository {
|
||||
new NodeAddress("izs5oz7i5ta7c2ir.onion:8000"),*/
|
||||
|
||||
// v0.3.5, v0.3.6 (backwards compatible)
|
||||
new NodeAddress("hulvbm5xjn7b7ku4.onion:8000"),
|
||||
/*new NodeAddress("hulvbm5xjn7b7ku4.onion:8000"),
|
||||
new NodeAddress("3efgjjbdvhbvck3x.onion:8000"),
|
||||
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),
|
||||
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),*/
|
||||
|
||||
|
||||
// v0.3.7
|
||||
/* new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
|
||||
new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
|
||||
new NodeAddress("ufwnvo775jfnjeux.onion:8000"),
|
||||
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),*/
|
||||
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),
|
||||
|
||||
// testnet
|
||||
new NodeAddress("znmy44wcstn2rkva.onion:8001"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user