add prune cli switch

This commit is contained in:
andri lim 2018-11-30 10:03:30 +07:00
parent a5aad977dd
commit 87541b8cb7
1 changed files with 21 additions and 0 deletions

View File

@ -134,6 +134,10 @@ type
## Debug configuration object ## Debug configuration object
flags*: set[DebugFlags] ## Debug flags flags*: set[DebugFlags] ## Debug flags
PruneMode* {.pure.} = enum
Full
Archive
ChainConfig* = object ChainConfig* = object
chainId*: uint chainId*: uint
homesteadBlock*: BlockNumber homesteadBlock*: BlockNumber
@ -154,6 +158,7 @@ type
## Main Nimbus configuration object ## Main Nimbus configuration object
dataDir*: string dataDir*: string
keyFile*: string keyFile*: string
prune*: PruneMode
rpc*: RpcConfiguration ## JSON-RPC configuration rpc*: RpcConfiguration ## JSON-RPC configuration
net*: NetConfiguration ## Network configuration net*: NetConfiguration ## Network configuration
debug*: DebugConfiguration ## Debug configuration debug*: DebugConfiguration ## Debug configuration
@ -313,6 +318,18 @@ proc processPrivateKey(v: string, o: var PrivateKey): ConfigStatus =
# except: # except:
# result = ErrorParseOption # result = ErrorParseOption
proc processPruneList(v: string, flags: var PruneMode): ConfigStatus =
var list = newSeq[string]()
processList(v, list)
result = Success
for item in list:
case item.toLowerAscii()
of "full": flags = PruneMode.Full
of "archive": flags = PruneMode.Archive
else:
warn "unknown prune flags", name = item
result = ErrorIncorrectOption
proc processEthArguments(key, value: string): ConfigStatus = proc processEthArguments(key, value: string): ConfigStatus =
result = Success result = Success
let config = getConfiguration() let config = getConfiguration()
@ -324,6 +341,8 @@ proc processEthArguments(key, value: string): ConfigStatus =
result = ErrorIncorrectOption result = ErrorIncorrectOption
of "dataDir": of "dataDir":
config.dataDir = value config.dataDir = value
of "prune":
result = processPruneList(value, config.prune)
else: else:
result = EmptyOption result = EmptyOption
@ -514,6 +533,7 @@ proc initConfiguration(): NimbusConfiguration =
".cache" / "nimbus" / "db" ".cache" / "nimbus" / "db"
result.dataDir = getHomeDir() / dataDir result.dataDir = getHomeDir() / dataDir
result.prune = PruneMode.Full
## Debug defaults ## Debug defaults
result.debug.flags = {} result.debug.flags = {}
@ -533,6 +553,7 @@ USAGE:
ETHEREUM OPTIONS: ETHEREUM OPTIONS:
--keyfile:<value> Use keyfile storage file --keyfile:<value> Use keyfile storage file
--datadir:<value> Base directory for all blockchain-related data --datadir:<value> Base directory for all blockchain-related data
--prune:<value> Blockchain prune mode(full or archive)
NETWORKING OPTIONS: NETWORKING OPTIONS:
--bootnodes:<value> Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers) --bootnodes:<value> Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)