From 87541b8cb7ac3dccfae8957f47c8f05f5fd3aee3 Mon Sep 17 00:00:00 2001 From: andri lim Date: Fri, 30 Nov 2018 10:03:30 +0700 Subject: [PATCH] add prune cli switch --- nimbus/config.nim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/nimbus/config.nim b/nimbus/config.nim index 758346039..939fb777a 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -134,6 +134,10 @@ type ## Debug configuration object flags*: set[DebugFlags] ## Debug flags + PruneMode* {.pure.} = enum + Full + Archive + ChainConfig* = object chainId*: uint homesteadBlock*: BlockNumber @@ -154,6 +158,7 @@ type ## Main Nimbus configuration object dataDir*: string keyFile*: string + prune*: PruneMode rpc*: RpcConfiguration ## JSON-RPC configuration net*: NetConfiguration ## Network configuration debug*: DebugConfiguration ## Debug configuration @@ -313,6 +318,18 @@ proc processPrivateKey(v: string, o: var PrivateKey): ConfigStatus = # except: # 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 = result = Success let config = getConfiguration() @@ -324,6 +341,8 @@ proc processEthArguments(key, value: string): ConfigStatus = result = ErrorIncorrectOption of "dataDir": config.dataDir = value + of "prune": + result = processPruneList(value, config.prune) else: result = EmptyOption @@ -514,6 +533,7 @@ proc initConfiguration(): NimbusConfiguration = ".cache" / "nimbus" / "db" result.dataDir = getHomeDir() / dataDir + result.prune = PruneMode.Full ## Debug defaults result.debug.flags = {} @@ -533,6 +553,7 @@ USAGE: ETHEREUM OPTIONS: --keyfile: Use keyfile storage file --datadir: Base directory for all blockchain-related data + --prune: Blockchain prune mode(full or archive) NETWORKING OPTIONS: --bootnodes: Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)