use of bisq.core.btc.BitcoinNodes.BitcoinNodesOption in project bisq-core by bisq-network.
the class WalletSetupPreferences method selectPreferredNodes.
List<BtcNode> selectPreferredNodes(BitcoinNodes nodes) {
List<BtcNode> result;
BitcoinNodesOption nodesOption = BitcoinNodesOption.values()[preferences.getBitcoinNodesOptionOrdinal()];
switch(nodesOption) {
case CUSTOM:
String bitcoinNodes = preferences.getBitcoinNodes();
Set<String> distinctNodes = Utilities.commaSeparatedListToSet(bitcoinNodes, false);
result = BitcoinNodes.toBtcNodesList(distinctNodes);
if (result.isEmpty()) {
log.warn("Custom nodes is set but no valid nodes are provided. " + "We fall back to provided nodes option.");
preferences.setBitcoinNodesOptionOrdinal(BitcoinNodesOption.PROVIDED.ordinal());
result = nodes.getProvidedBtcNodes();
}
break;
case PUBLIC:
result = Collections.emptyList();
break;
case PROVIDED:
default:
result = nodes.getProvidedBtcNodes();
break;
}
return result;
}
use of bisq.core.btc.BitcoinNodes.BitcoinNodesOption in project bisq-core by bisq-network.
the class WalletSetupPreferences method calculateMinBroadcastConnections.
int calculateMinBroadcastConnections(List<BtcNode> nodes) {
BitcoinNodesOption nodesOption = BitcoinNodesOption.values()[preferences.getBitcoinNodesOptionOrdinal()];
int result;
switch(nodesOption) {
case CUSTOM:
// We have set the nodes already above
result = (int) Math.ceil(nodes.size() * 0.5);
// but if user provides mixed clear net and onion nodes we want to use both
break;
case PUBLIC:
// We keep the empty nodes
result = (int) Math.floor(DEFAULT_CONNECTIONS * 0.8);
break;
case PROVIDED:
default:
// We require only 4 nodes instead of 7 (for 9 max connections) because our provided nodes
// are more reliable than random public nodes.
result = 4;
break;
}
return result;
}
Aggregations