Skip to content

Commit

Permalink
Update Fluffy data directory location based on selected network. (#2400)
Browse files Browse the repository at this point in the history
  • Loading branch information
web3-developer committed Jun 20, 2024
1 parent 0b83637 commit bd2ca07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions fluffy/fluffy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{.push raises: [].}

import
std/os,
std/[os, enumutils],
confutils,
confutils/std/net,
chronicles,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion fluffy/network/beacon/beacon_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit bd2ca07

Please sign in to comment.