From 651a9453298bab02810c6a97861d2f1a3ff00af9 Mon Sep 17 00:00:00 2001 From: Volodymyr Kravets Date: Tue, 16 Jan 2024 15:20:53 +0200 Subject: [PATCH] Made bucketSize value configurable --- rskj-core/src/main/java/co/rsk/RskContext.java | 3 ++- .../src/main/java/co/rsk/config/RskSystemProperties.java | 6 ++++++ rskj-core/src/main/resources/expected.conf | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rskj-core/src/main/java/co/rsk/RskContext.java b/rskj-core/src/main/java/co/rsk/RskContext.java index 2d6f24fa06c..a73129564ce 100644 --- a/rskj-core/src/main/java/co/rsk/RskContext.java +++ b/rskj-core/src/main/java/co/rsk/RskContext.java @@ -1588,10 +1588,11 @@ protected PeerExplorer getPeerExplorer() { initialBootNodes.add(address.getHostName() + ":" + address.getPort()); } } + int bucketSize = rskSystemProperties.discoveryBucketSize(); peerExplorer = new PeerExplorer( initialBootNodes, localNode, - new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE, localNode), + new NodeDistanceTable(KademliaOptions.BINS, bucketSize, localNode), key, rskSystemProperties.peerDiscoveryMessageTimeOut(), rskSystemProperties.peerDiscoveryRefreshPeriod(), diff --git a/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java b/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java index ad411a32043..aba915edfcd 100644 --- a/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java +++ b/rskj-core/src/main/java/co/rsk/config/RskSystemProperties.java @@ -19,6 +19,7 @@ package co.rsk.config; import co.rsk.core.RskAddress; +import co.rsk.net.discovery.table.KademliaOptions; import co.rsk.rpc.ModuleDescription; import com.typesafe.config.Config; import com.typesafe.config.ConfigObject; @@ -54,6 +55,7 @@ public class RskSystemProperties extends SystemProperties { private static final String RPC_MODULES_PATH = "rpc.modules"; private static final String RPC_ETH_GET_LOGS_MAX_BLOCKS_TO_QUERY = "rpc.logs.maxBlocksToQuery"; private static final String RPC_ETH_GET_LOGS_MAX_LOGS_TO_RETURN = "rpc.logs.maxLogsToReturn"; + private static final String DISCOVERY_BUCKET_SIZE = "peer.discovery.bucketSize"; private static final int CHUNK_SIZE = 192; @@ -249,6 +251,10 @@ public boolean allowMultipleConnectionsPerHostPort() { return getBoolean("peer.discovery.allowMultipleConnectionsPerHostPort", true); } + public int discoveryBucketSize() { + return getInt(DISCOVERY_BUCKET_SIZE, KademliaOptions.BUCKET_SIZE); + } + public List getRpcModules() { if (this.moduleDescriptions != null) { return this.moduleDescriptions; diff --git a/rskj-core/src/main/resources/expected.conf b/rskj-core/src/main/resources/expected.conf index dec928794e5..9714c4b5421 100644 --- a/rskj-core/src/main/resources/expected.conf +++ b/rskj-core/src/main/resources/expected.conf @@ -135,6 +135,7 @@ peer = { msg.timeout = refresh.period = allowMultipleConnectionsPerHostPort = + bucketSize = } port = networkId =