mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-09-24 06:54:46 -04:00
Remove check for not empty seednodes (can be empty in some cases)
This commit is contained in:
parent
e7967cc0e1
commit
605cf27eaf
4 changed files with 24 additions and 19 deletions
|
@ -93,6 +93,7 @@ public class PeerManager implements ConnectionListener {
|
||||||
public PeerManager(NetworkNode networkNode, Set<NodeAddress> seedNodeAddresses, File storageDir, Clock clock) {
|
public PeerManager(NetworkNode networkNode, Set<NodeAddress> seedNodeAddresses, File storageDir, Clock clock) {
|
||||||
this.networkNode = networkNode;
|
this.networkNode = networkNode;
|
||||||
this.clock = clock;
|
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);
|
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||||
networkNode.addConnectionListener(this);
|
networkNode.addConnectionListener(this);
|
||||||
dbStorage = new Storage<>(storageDir);
|
dbStorage = new Storage<>(storageDir);
|
||||||
|
|
|
@ -69,10 +69,10 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||||
this.networkNode = networkNode;
|
this.networkNode = networkNode;
|
||||||
this.dataStorage = dataStorage;
|
this.dataStorage = dataStorage;
|
||||||
this.peerManager = peerManager;
|
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.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
checkArgument(!seedNodeAddresses.isEmpty(), "seedNodeAddresses must not be empty.");
|
|
||||||
networkNode.addMessageListener(this);
|
networkNode.addMessageListener(this);
|
||||||
peerManager.addListener(this);
|
peerManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
@ -94,22 +94,26 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||||
public void requestPreliminaryData() {
|
public void requestPreliminaryData() {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
ArrayList<NodeAddress> nodeAddresses = new ArrayList<>(seedNodeAddresses);
|
ArrayList<NodeAddress> nodeAddresses = new ArrayList<>(seedNodeAddresses);
|
||||||
|
if (!nodeAddresses.isEmpty()) {
|
||||||
Collections.shuffle(nodeAddresses);
|
Collections.shuffle(nodeAddresses);
|
||||||
NodeAddress nextCandidate = nodeAddresses.get(0);
|
NodeAddress nextCandidate = nodeAddresses.get(0);
|
||||||
nodeAddresses.remove(nextCandidate);
|
nodeAddresses.remove(nextCandidate);
|
||||||
requestData(nextCandidate, nodeAddresses);
|
requestData(nextCandidate, nodeAddresses);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void requestUpdateData() {
|
public void requestUpdateData() {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
checkArgument(nodeAddressOfPreliminaryDataRequest.isPresent(), "seedNodeOfPreliminaryDataRequest must be present");
|
checkArgument(nodeAddressOfPreliminaryDataRequest.isPresent(), "seedNodeOfPreliminaryDataRequest must be present");
|
||||||
dataUpdateRequested = true;
|
dataUpdateRequested = true;
|
||||||
List<NodeAddress> remainingNodeAddresses = new ArrayList<>(seedNodeAddresses);
|
List<NodeAddress> remainingNodeAddresses = new ArrayList<>(seedNodeAddresses);
|
||||||
|
if (!remainingNodeAddresses.isEmpty()) {
|
||||||
Collections.shuffle(remainingNodeAddresses);
|
Collections.shuffle(remainingNodeAddresses);
|
||||||
NodeAddress candidate = nodeAddressOfPreliminaryDataRequest.get();
|
NodeAddress candidate = nodeAddressOfPreliminaryDataRequest.get();
|
||||||
remainingNodeAddresses.remove(candidate);
|
remainingNodeAddresses.remove(candidate);
|
||||||
requestData(candidate, remainingNodeAddresses);
|
requestData(candidate, remainingNodeAddresses);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<NodeAddress> getNodeAddressOfPreliminaryDataRequest() {
|
public Optional<NodeAddress> getNodeAddressOfPreliminaryDataRequest() {
|
||||||
return nodeAddressOfPreliminaryDataRequest;
|
return nodeAddressOfPreliminaryDataRequest;
|
||||||
|
@ -315,10 +319,11 @@ public class RequestDataManager implements MessageListener, ConnectionListener,
|
||||||
List<NodeAddress> filteredPersistedPeers = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getPersistedPeers()), list);
|
List<NodeAddress> filteredPersistedPeers = getFilteredNonSeedNodeList(getSortedNodeAddresses(peerManager.getPersistedPeers()), list);
|
||||||
list.addAll(filteredPersistedPeers);
|
list.addAll(filteredPersistedPeers);
|
||||||
|
|
||||||
checkArgument(!list.isEmpty(), "seedNodeAddresses must not be empty.");
|
if (!list.isEmpty()) {
|
||||||
NodeAddress nextCandidate = list.get(0);
|
NodeAddress nextCandidate = list.get(0);
|
||||||
list.remove(nextCandidate);
|
list.remove(nextCandidate);
|
||||||
requestData(nextCandidate, list);
|
requestData(nextCandidate, list);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
RETRY_DELAY_SEC);
|
RETRY_DELAY_SEC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class PeerExchangeManager implements MessageListener, ConnectionListener, PeerManager.Listener {
|
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) {
|
public PeerExchangeManager(NetworkNode networkNode, PeerManager peerManager, Set<NodeAddress> seedNodeAddresses) {
|
||||||
this.networkNode = networkNode;
|
this.networkNode = networkNode;
|
||||||
this.peerManager = peerManager;
|
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);
|
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||||
|
|
||||||
networkNode.addMessageListener(this);
|
networkNode.addMessageListener(this);
|
||||||
|
|
|
@ -32,15 +32,15 @@ public class SeedNodesRepository {
|
||||||
new NodeAddress("izs5oz7i5ta7c2ir.onion:8000"),*/
|
new NodeAddress("izs5oz7i5ta7c2ir.onion:8000"),*/
|
||||||
|
|
||||||
// v0.3.5, v0.3.6 (backwards compatible)
|
// 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("3efgjjbdvhbvck3x.onion:8000"),
|
||||||
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),
|
new NodeAddress("3unfcshgwipxhxfm.onion:8000"),*/
|
||||||
|
|
||||||
|
|
||||||
// v0.3.7
|
// v0.3.7
|
||||||
/* new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
|
new NodeAddress("ybmi4iaesugslxrw.onion:8000"),
|
||||||
new NodeAddress("ufwnvo775jfnjeux.onion:8000"),
|
new NodeAddress("ufwnvo775jfnjeux.onion:8000"),
|
||||||
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),*/
|
new NodeAddress("b66vnevaljo6xt5a.onion:8000"),
|
||||||
|
|
||||||
// testnet
|
// testnet
|
||||||
new NodeAddress("znmy44wcstn2rkva.onion:8001"),
|
new NodeAddress("znmy44wcstn2rkva.onion:8001"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue