Don't add the 'node' log property when connecting to the testnet

This commit is contained in:
Zahary Karadjov 2019-03-20 13:52:30 +02:00 committed by zah
parent ca49ae9b5a
commit 06301458bf
3 changed files with 30 additions and 22 deletions

View File

@ -682,6 +682,27 @@ proc createPidFile(filename: string) =
gPidFile = filename
addQuitProc proc {.noconv.} = removeFile gPidFile
proc start(node: BeaconNode) =
# TODO: while it's nice to cheat by waiting for connections here, we
# actually need to make this part of normal application flow -
# losing all connections might happen at any time and we should be
# prepared to handle it.
waitFor node.connectToNetwork()
if not waitFor node.sync():
quit 1
info "Starting beacon node",
slotsSinceFinalization = node.state.data.slotDistanceFromNow(),
stateSlot = humaneSlotNum(node.state.data.slot),
SHARD_COUNT,
SLOTS_PER_EPOCH,
SECONDS_PER_SLOT,
SPEC_VERSION
node.addLocalValidators()
node.run()
when isMainModule:
let config = BeaconNodeConf.load(version = fullVersionStr())
@ -760,23 +781,8 @@ when isMainModule:
var node = waitFor BeaconNode.init(config)
dynamicLogScope(node = node.config.tcpPort - 50000):
# TODO: while it's nice to cheat by waiting for connections here, we
# actually need to make this part of normal application flow -
# losing all connections might happen at any time and we should be
# prepared to handle it.
waitFor node.connectToNetwork()
if config.tcpPort != config.defaultPort:
dynamicLogScope(node = config.tcpPort): node.start()
else:
node.start()
if not waitFor node.sync():
quit 1
info "Starting beacon node",
slotsSinceFinalization = node.state.data.slotDistanceFromNow(),
stateSlot = humaneSlotNum(node.state.data.slot),
SHARD_COUNT,
SLOTS_PER_EPOCH,
SECONDS_PER_SLOT,
SPEC_VERSION
node.addLocalValidators()
node.run()

View File

@ -127,14 +127,14 @@ proc defaultDataDir*(conf: BeaconNodeConf): string =
else:
".cache" / "nimbus"
let networkId = if conf.network in ["testnet0", "testnet1", "mainnet"]:
let networkDir = if conf.network in ["testnet0", "testnet1", "mainnet"]:
conf.network
else:
# TODO: This seems silly. Perhaps we should error out here and ask
# the user to specify dataDir as well.
"tempnet"
getHomeDir() / dataDir / "BeaconNode" / networkId
getHomeDir() / dataDir / "BeaconNode" / networkDir
proc defaultPort*(conf: BeaconNodeConf): int =
(if conf.network == "testnet0": 9630 else: 9632) + ord(useRLPx)

View File

@ -29,7 +29,9 @@ regenTestnetFiles() {
--outputDir="$NETWORK_DIR"
fi
nim c -r $NIM_FLAGS beacon_chain/beacon_node --dataDir=$DATA_DIR/node-0 \
nim c -r $NIM_FLAGS beacon_chain/beacon_node \
--network=$NETWORK_NAME \
--dataDir=$DATA_DIR/node-0 \
createTestnet \
--networkId=$NETWORK_ID \
--validatorsDir=$NETWORK_DIR \