Skip to content

Commit

Permalink
Merge pull request #2228 from rsksmart/bucket-size-conf
Browse files Browse the repository at this point in the history
Made bucketSize value configurable
Vovchyk authored Jan 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 4c8c932 + 6faed39 commit 5395060
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rskj-core/src/main/java/co/rsk/RskContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -1590,10 +1590,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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class RskSystemProperties extends SystemProperties {
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 RPC_GAS_PRICE_MULTIPLIER_CONFIG = "rpc.gasPriceMultiplier";
private static final String DISCOVERY_BUCKET_SIZE = "peer.discovery.bucketSize";

private static final int CHUNK_SIZE = 192;

Expand Down Expand Up @@ -260,6 +262,10 @@ public boolean allowMultipleConnectionsPerHostPort() {
return getBoolean("peer.discovery.allowMultipleConnectionsPerHostPort", true);
}

public int discoveryBucketSize() {
return getInt(DISCOVERY_BUCKET_SIZE, KademliaOptions.BUCKET_SIZE);
}

public List<ModuleDescription> getRpcModules() {
if (this.moduleDescriptions != null) {
return this.moduleDescriptions;
Expand Down
1 change: 1 addition & 0 deletions rskj-core/src/main/resources/expected.conf
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ peer = {
msg.timeout = <long>
refresh.period = <long>
allowMultipleConnectionsPerHostPort = <bool>
bucketSize = <number>
}
port = <port>
networkId = <networkId>
Expand Down

0 comments on commit 5395060

Please sign in to comment.