Skip to content

Commit

Permalink
Pass filterProvidedBtcNodes and bannedBtcNodes to FederatedBtcNodePro…
Browse files Browse the repository at this point in the history
…vider
  • Loading branch information
alvasw committed Nov 18, 2024
1 parent bc6954e commit c4e82d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public List<BtcNode> selectPreferredNodes(BtcNodes btcNodes) {
case PROVIDED:
default:
List<BtcNode> hardcodedBtcNodes = btcNodes.getProvidedBtcNodes();
result = FederatedBtcNodeProvider.getNodes(hardcodedBtcNodes, config);
List<String> filterProvidedBtcNodes = config.filterProvidedBtcNodes;
List<String> bannedBtcNodes = config.bannedBtcNodes;
result = FederatedBtcNodeProvider.getNodes(hardcodedBtcNodes, filterProvidedBtcNodes, bannedBtcNodes);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import bisq.network.p2p.NodeAddress;

import bisq.common.config.Config;

import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand All @@ -16,16 +14,18 @@
@Slf4j
public class FederatedBtcNodeProvider {

static List<BtcNodes.BtcNode> getNodes(List<BtcNodes.BtcNode> hardcodedBtcNodes, Config config) {
Set<BtcNodes.BtcNode> filterProvidedBtcNodes = config.filterProvidedBtcNodes.stream()
static List<BtcNodes.BtcNode> getNodes(List<BtcNodes.BtcNode> hardcodedBtcNodes,
List<String> filterProvidedBtcNodesConfig,
List<String> bannedBtcNodesConfig) {
Set<BtcNodes.BtcNode> filterProvidedBtcNodes = filterProvidedBtcNodesConfig.stream()
.filter(n -> !n.isEmpty())
.map(FederatedBtcNodeProvider::getNodeAddress)
.filter(Objects::nonNull)
.map(nodeAddress -> new BtcNodes.BtcNode(null, nodeAddress.getHostName(), null, nodeAddress.getPort(), "Provided by filter"))
.collect(Collectors.toSet());
hardcodedBtcNodes.addAll(filterProvidedBtcNodes);

Set<String> bannedBtcNodeHostNames = config.bannedBtcNodes.stream()
Set<String> bannedBtcNodeHostNames = bannedBtcNodesConfig.stream()
.filter(n -> !n.isEmpty())
.map(FederatedBtcNodeProvider::getNodeAddress)
.filter(Objects::nonNull)
Expand Down

0 comments on commit c4e82d5

Please sign in to comment.