From 3fc3ba925efe78b748d8c115d792065e124fbf44 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 25 Mar 2020 20:00:04 +0200 Subject: [PATCH] Compile Nimbus with Nim 1.2 --- nimbus/nimbus.nim | 42 +++++++++++++++++------------------ vendor/nim-chronicles | 2 +- vendor/nim-chronos | 2 +- vendor/nim-eth | 2 +- vendor/nim-json-rpc | 2 +- vendor/nim-json-serialization | 2 +- vendor/nim-serialization | 2 +- vendor/nimbus-build-system | 2 +- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/nimbus/nimbus.nim b/nimbus/nimbus.nim index c2a3da651..27894bbf3 100644 --- a/nimbus/nimbus.nim +++ b/nimbus/nimbus.nim @@ -32,28 +32,15 @@ type NimbusState = enum Starting, Running, Stopping, Stopped - NimbusObject = ref object + NimbusNode = ref object rpcServer*: RpcHttpServer ethNode*: EthereumNode state*: NimbusState -var nimbus: NimbusObject - -proc start() = +proc start(nimbus: NimbusNode) = var conf = getConfiguration() - - nimbus = NimbusObject() nimbus.state = Starting - ## Ctrl+C handling - proc controlCHandler() {.noconv.} = - when defined(windows): - # workaround for https://github.com/nim-lang/Nim/issues/4057 - setupForeignThreadGc() - nimbus.state = Stopping - echo "\nCtrl+C pressed. Waiting for a graceful shutdown." - setControlCHook(controlCHandler) - ## logging setLogLevel(conf.debug.logLevel) if len(conf.debug.logFile) != 0: @@ -113,7 +100,7 @@ proc start() = if canonicalHeadHashKey().toOpenArray notin trieDB: initializeEmptyDb(chainDb) doAssert(canonicalHeadHashKey().toOpenArray in trieDB) - + nimbus.ethNode = newEthereumNode(keypair, address, conf.net.networkId, nil, nimbusClientId, addAllCapabilities = false, @@ -145,7 +132,7 @@ proc start() = nimbus.state = Stopping result = "EXITING" nimbus.rpcServer.start() - + # metrics server when defined(insecure): if conf.net.metricsServer: @@ -171,13 +158,13 @@ proc start() = # it might have been set to "Stopping" with Ctrl+C nimbus.state = Running -proc stop*() {.async.} = +proc stop*(nimbus: NimbusNode) {.async, gcsafe.} = trace "Graceful shutdown" var conf = getConfiguration() if RpcFlags.Enabled in conf.rpc.flags: nimbus.rpcServer.stop() -proc process*() = +proc process*(nimbus: NimbusNode) = if nimbus.state == Running: # Main loop while nimbus.state == Running: @@ -187,9 +174,20 @@ proc process*() = debug "Exception in poll()", exc = e.name, err = e.msg # Stop loop - waitFor stop() + waitFor nimbus.stop() when isMainModule: + var nimbus = NimbusNode() + + ## Ctrl+C handling + proc controlCHandler() {.noconv.} = + when defined(windows): + # workaround for https://github.com/nim-lang/Nim/issues/4057 + setupForeignThreadGc() + nimbus.state = Stopping + echo "\nCtrl+C pressed. Waiting for a graceful shutdown." + setControlCHook(controlCHandler) + var message: string ## Print Nimbus header @@ -207,6 +205,6 @@ when isMainModule: echo message quit(QuitSuccess) - start() - process() + nimbus.start() + nimbus.process() diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index 81aebe6a8..8da0e30c5 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit 81aebe6a8955b9c6c598aaf36d2c3ff8edc0e5fa +Subproject commit 8da0e30c526ab1c6c825e16546fc5db972c5408d diff --git a/vendor/nim-chronos b/vendor/nim-chronos index c39c06968..f3827a13d 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit c39c0696806a0ef09bc90e477ea6b177d2824699 +Subproject commit f3827a13d12f27e20874df81dc99b55e5dc78244 diff --git a/vendor/nim-eth b/vendor/nim-eth index 9c442bf65..c3f23e591 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 9c442bf65b52a4c857cc6e51efe901352e8b6ebf +Subproject commit c3f23e5912efff98fc6c8181db579037e5a19a2c diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc index 09f6fd635..5c0d09611 160000 --- a/vendor/nim-json-rpc +++ b/vendor/nim-json-rpc @@ -1 +1 @@ -Subproject commit 09f6fd63556a22312af7c5a7e3fa105b26897316 +Subproject commit 5c0d0961114bcaaf3da52d5918bf0b85ef0e4ce9 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization index 88b79e230..c108ba90e 160000 --- a/vendor/nim-json-serialization +++ b/vendor/nim-json-serialization @@ -1 +1 @@ -Subproject commit 88b79e230005d8301c3ae950abdbf8ad55e37f19 +Subproject commit c108ba90e6b304515f08fdcff62f428f3f8fbe53 diff --git a/vendor/nim-serialization b/vendor/nim-serialization index ae60eef4e..0eab8cfee 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit ae60eef4e8413e49fb0dbcae9a343fb479509fa0 +Subproject commit 0eab8cfeee55cfa3bb893ec31137d3c25b83a1ae diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index 2c4faa537..53c12ddae 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit 2c4faa5372d2d8b0c2d16710fe5f93beab1c86af +Subproject commit 53c12ddae315731f5cd4d1d71fff57b4836a9c2d