Merge 9d0fec5721e256804aed0adf01df5197293d2566 into cf2f40f5591ce9e75e49b5c7e70d2ec53d296cfd

This commit is contained in:
Arnaud 2026-05-07 10:25:52 +04:00 committed by GitHub
commit e503e946d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 25 deletions

View File

@ -272,15 +272,22 @@ type
name: "block-retries"
.}: int
cacheSize* {.
discoveryTableIpLimit* {.
desc: "Maximum number of nodes with the same IP in the discovery routing table",
defaultValue: 10'u,
defaultValueDesc: "10",
name: "discovery-table-ip-limit",
hidden
.}: uint
discoveryBucketIpLimit* {.
desc:
"The size of the block cache, 0 disables the cache - " &
"might help on slow hardrives",
defaultValue: 0,
defaultValueDesc: "0",
name: "cache-size",
abbr: "c"
.}: NBytes
"Maximum number of nodes with the same IP per bucket in the discovery routing table",
defaultValue: 2'u,
defaultValueDesc: "2",
name: "discovery-bucket-ip-limit",
hidden
.}: uint
logFile* {.
desc: "Logs to file", defaultValue: string.none, name: "log-file", hidden

View File

@ -240,6 +240,7 @@ proc new*(
announceAddrs: openArray[MultiAddress],
bootstrapNodes: openArray[SignedPeerRecord] = [],
store: Datastore = SQLiteDatastore.new(Memory).expect("Should not fail!"),
tableIpLimits: TableIpLimits = DefaultTableIpLimits,
): Discovery =
## Create a new Discovery node instance for the given key and datastore
##
@ -250,14 +251,8 @@ proc new*(
self.updateAnnounceRecord(announceAddrs)
# --------------------------------------------------------------------------
# FIXME disable IP limits temporarily so we can run our workshop. Re-enable
# and figure out proper solution.
let discoveryConfig = DiscoveryConfig(
tableIpLimits: TableIpLimits(tableIpLimit: high(uint), bucketIpLimit: high(uint)),
bitsPerHop: DefaultBitsPerHop,
)
# --------------------------------------------------------------------------
let discoveryConfig =
DiscoveryConfig(tableIpLimits: tableIpLimits, bitsPerHop: DefaultBitsPerHop)
self.protocol = newProtocol(
key,

View File

@ -184,9 +184,7 @@ proc new*(
.withTcpTransport({ServerFlags.ReuseAddr, ServerFlags.TcpNoDelay})
.build()
var
cache: CacheStore = nil
taskPool: Taskpool
var taskPool: Taskpool
try:
if config.numThreads == ThreadCount(0):
@ -197,10 +195,6 @@ proc new*(
except CatchableError as exc:
raiseAssert("Failure in taskPool initialization:" & exc.msg)
if config.cacheSize > 0'nb:
cache = CacheStore.new(cacheSize = config.cacheSize)
## Is unused?
let discoveryDir = config.dataDir / StorageDhtNamespace
if io2.createPath(discoveryDir).isErr:

View File

@ -5,6 +5,7 @@ import pkg/taskpools
import pkg/libp2p
import pkg/libp2p/errors
import pkg/codexdht/discv5/routing_table
import pkg/storage/discovery
import pkg/storage/stores
import pkg/storage/blocktype as bt
@ -180,6 +181,8 @@ proc generateNodes*(
bindPort = bindPort.Port,
store = blockDiscoveryStore,
bootstrapNodes = bootstrapNodes,
tableIpLimits =
TableIpLimits(tableIpLimit: high(uint), bucketIpLimit: high(uint)),
)
else:
nullDiscovery()
@ -189,8 +192,12 @@ proc generateNodes*(
else:
let
store = CacheStore.new(blocks.mapIt(it))
discovery =
Discovery.new(switch.peerInfo.privateKey, announceAddrs = @[listenAddr])
discovery = Discovery.new(
switch.peerInfo.privateKey,
announceAddrs = @[listenAddr],
tableIpLimits =
TableIpLimits(tableIpLimit: high(uint), bucketIpLimit: high(uint)),
)
(store.BlockStore, newSeq[TempLevelDb](), discovery)
let