Update Fluffy data directory location based on selected network. (#2400)

This commit is contained in:
web3-developer 2024-06-20 10:48:45 +08:00 committed by GitHub
parent 0b8363764d
commit bd2ca07da6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -8,7 +8,7 @@
{.push raises: [].}
import
std/os,
std/[os, enumutils],
confutils,
confutils/std/net,
chronicles,
@ -60,6 +60,12 @@ proc onOptimisticHeader(
when lcDataFork > LightClientDataFork.None:
info "New LC optimistic header", optimistic_header = shortLog(forkyHeader)
proc getDbDirectory(network: PortalNetwork): string =
if network == PortalNetwork.mainnet:
"db"
else:
"db_" & network.symbolName()
proc run(config: PortalConf) {.raises: [CatchableError].} =
setupLogging(config.logLevel, config.logStdout)
@ -163,7 +169,7 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
# Force pruning
if config.forcePrune:
let db = ContentDB.new(
config.dataDir / "db" / "contentdb_" &
config.dataDir / portalNetwork.getDbDirectory() / "contentdb_" &
d.localNode.id.toBytesBE().toOpenArray(0, 8).toHex(),
storageCapacity = config.storageCapacityMB * 1_000_000,
manualCheckpoint = true,
@ -195,7 +201,7 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
# the selected `Radius`.
let
db = ContentDB.new(
config.dataDir / "db" / "contentdb_" &
config.dataDir / portalNetwork.getDbDirectory() / "contentdb_" &
d.localNode.id.toBytesBE().toOpenArray(0, 8).toHex(),
storageCapacity = config.storageCapacityMB * 1_000_000,
)
@ -260,7 +266,6 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
config.trustedBlockRoot.isSome():
let
# Portal works only over mainnet data currently
# TODO: investigate this load network data function
networkData = loadNetworkData("mainnet")
beaconDb = BeaconDb.new(networkData, config.dataDir / "db" / "beacon_db")
beaconNetwork = BeaconNetwork.new(

View File

@ -324,7 +324,7 @@ proc processContentLoop(n: BeaconNetwork) {.async: (raises: []).} =
trace "processContentLoop canceled"
proc start*(n: BeaconNetwork) =
info "Starting portal beacon chain network"
info "Starting Portal beacon chain network"
n.portalProtocol.start()
n.processContentLoop = processContentLoop(n)