fix persist tool to support testnet
This commit is contained in:
parent
3931c1ff5c
commit
2e583e9aa0
|
@ -1,5 +1,5 @@
|
|||
import stint, os, parseopt, strutils
|
||||
from ../nimbus/config import getDefaultDataDir, ConfigStatus, processInteger
|
||||
from ../nimbus/config import getDefaultDataDir, ConfigStatus, processInteger, PublicNetwork
|
||||
|
||||
export ConfigStatus
|
||||
|
||||
|
@ -9,6 +9,7 @@ type
|
|||
head*: Uint256
|
||||
maxBlocks*: int
|
||||
numCommits*: int
|
||||
netId*: PublicNetwork
|
||||
|
||||
var premixConfig {.threadvar.}: PremixConfiguration
|
||||
|
||||
|
@ -23,6 +24,7 @@ proc initConfiguration(): PremixConfiguration =
|
|||
result.head = 0.u256
|
||||
result.maxBlocks = 0
|
||||
result.numCommits = 128
|
||||
result.netId = MainNet
|
||||
|
||||
proc getConfiguration*(): PremixConfiguration =
|
||||
if isNil(premixConfig):
|
||||
|
@ -36,6 +38,15 @@ proc processU256(val: string, o: var Uint256): ConfigStatus =
|
|||
o = parse(val, Uint256)
|
||||
result = Success
|
||||
|
||||
proc processNetId(val: string, o: var PublicNetwork): ConfigStatus =
|
||||
case val.toLowerAscii()
|
||||
of "main": o = MainNet
|
||||
of "morden": o = MordenNet
|
||||
of "ropsten": o = RopstenNet
|
||||
of "rinkeby": o = RinkebyNet
|
||||
of "goerli": o = GoerliNet
|
||||
of "kovan": o = KovanNet
|
||||
|
||||
template checkArgument(fun, o: untyped) =
|
||||
## Checks if arguments got processed successfully
|
||||
var res = (fun)(value, o)
|
||||
|
@ -72,6 +83,8 @@ proc processArguments*(msg: var string): ConfigStatus =
|
|||
of "numcommits":
|
||||
checkArgument processInteger, config.numCommits
|
||||
config.numCommits = max(config.numCommits, 512)
|
||||
of "netid":
|
||||
checkArgument processNetId, config.netId
|
||||
else:
|
||||
msg = "Unknown option " & key
|
||||
if value.len > 0: msg = msg & " : " & value
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import
|
||||
eth/[common, rlp], stint,
|
||||
chronicles, downloader, configuration,
|
||||
../nimbus/errors
|
||||
../nimbus/[errors, config]
|
||||
|
||||
import
|
||||
eth/trie/[hexary, db],
|
||||
|
@ -34,10 +34,10 @@ proc main() =
|
|||
# 52029 first block with receipts logs
|
||||
# 66407 failed transaction
|
||||
|
||||
let conf = getConfiguration()
|
||||
let conf = configuration.getConfiguration()
|
||||
let db = newChainDb(conf.dataDir)
|
||||
let trieDB = trieDB db
|
||||
let chainDB = newBaseChainDB(trieDB, false)
|
||||
let chainDB = newBaseChainDB(trieDB, false, conf.netId)
|
||||
|
||||
# move head to block number ...
|
||||
if conf.head != 0.u256:
|
||||
|
@ -93,7 +93,7 @@ when isMainModule:
|
|||
var message: string
|
||||
|
||||
## Processing command line arguments
|
||||
if processArguments(message) != Success:
|
||||
if configuration.processArguments(message) != Success:
|
||||
echo message
|
||||
quit(QuitFailure)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue