Compile Nimbus with Nim 1.2
This commit is contained in:
parent
7a721c58af
commit
3fc3ba925e
|
@ -32,28 +32,15 @@ type
|
||||||
NimbusState = enum
|
NimbusState = enum
|
||||||
Starting, Running, Stopping, Stopped
|
Starting, Running, Stopping, Stopped
|
||||||
|
|
||||||
NimbusObject = ref object
|
NimbusNode = ref object
|
||||||
rpcServer*: RpcHttpServer
|
rpcServer*: RpcHttpServer
|
||||||
ethNode*: EthereumNode
|
ethNode*: EthereumNode
|
||||||
state*: NimbusState
|
state*: NimbusState
|
||||||
|
|
||||||
var nimbus: NimbusObject
|
proc start(nimbus: NimbusNode) =
|
||||||
|
|
||||||
proc start() =
|
|
||||||
var conf = getConfiguration()
|
var conf = getConfiguration()
|
||||||
|
|
||||||
nimbus = NimbusObject()
|
|
||||||
nimbus.state = Starting
|
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
|
## logging
|
||||||
setLogLevel(conf.debug.logLevel)
|
setLogLevel(conf.debug.logLevel)
|
||||||
if len(conf.debug.logFile) != 0:
|
if len(conf.debug.logFile) != 0:
|
||||||
|
@ -113,7 +100,7 @@ proc start() =
|
||||||
if canonicalHeadHashKey().toOpenArray notin trieDB:
|
if canonicalHeadHashKey().toOpenArray notin trieDB:
|
||||||
initializeEmptyDb(chainDb)
|
initializeEmptyDb(chainDb)
|
||||||
doAssert(canonicalHeadHashKey().toOpenArray in trieDB)
|
doAssert(canonicalHeadHashKey().toOpenArray in trieDB)
|
||||||
|
|
||||||
nimbus.ethNode = newEthereumNode(keypair, address, conf.net.networkId,
|
nimbus.ethNode = newEthereumNode(keypair, address, conf.net.networkId,
|
||||||
nil, nimbusClientId,
|
nil, nimbusClientId,
|
||||||
addAllCapabilities = false,
|
addAllCapabilities = false,
|
||||||
|
@ -145,7 +132,7 @@ proc start() =
|
||||||
nimbus.state = Stopping
|
nimbus.state = Stopping
|
||||||
result = "EXITING"
|
result = "EXITING"
|
||||||
nimbus.rpcServer.start()
|
nimbus.rpcServer.start()
|
||||||
|
|
||||||
# metrics server
|
# metrics server
|
||||||
when defined(insecure):
|
when defined(insecure):
|
||||||
if conf.net.metricsServer:
|
if conf.net.metricsServer:
|
||||||
|
@ -171,13 +158,13 @@ proc start() =
|
||||||
# it might have been set to "Stopping" with Ctrl+C
|
# it might have been set to "Stopping" with Ctrl+C
|
||||||
nimbus.state = Running
|
nimbus.state = Running
|
||||||
|
|
||||||
proc stop*() {.async.} =
|
proc stop*(nimbus: NimbusNode) {.async, gcsafe.} =
|
||||||
trace "Graceful shutdown"
|
trace "Graceful shutdown"
|
||||||
var conf = getConfiguration()
|
var conf = getConfiguration()
|
||||||
if RpcFlags.Enabled in conf.rpc.flags:
|
if RpcFlags.Enabled in conf.rpc.flags:
|
||||||
nimbus.rpcServer.stop()
|
nimbus.rpcServer.stop()
|
||||||
|
|
||||||
proc process*() =
|
proc process*(nimbus: NimbusNode) =
|
||||||
if nimbus.state == Running:
|
if nimbus.state == Running:
|
||||||
# Main loop
|
# Main loop
|
||||||
while nimbus.state == Running:
|
while nimbus.state == Running:
|
||||||
|
@ -187,9 +174,20 @@ proc process*() =
|
||||||
debug "Exception in poll()", exc = e.name, err = e.msg
|
debug "Exception in poll()", exc = e.name, err = e.msg
|
||||||
|
|
||||||
# Stop loop
|
# Stop loop
|
||||||
waitFor stop()
|
waitFor nimbus.stop()
|
||||||
|
|
||||||
when isMainModule:
|
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
|
var message: string
|
||||||
|
|
||||||
## Print Nimbus header
|
## Print Nimbus header
|
||||||
|
@ -207,6 +205,6 @@ when isMainModule:
|
||||||
echo message
|
echo message
|
||||||
quit(QuitSuccess)
|
quit(QuitSuccess)
|
||||||
|
|
||||||
start()
|
nimbus.start()
|
||||||
process()
|
nimbus.process()
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 81aebe6a8955b9c6c598aaf36d2c3ff8edc0e5fa
|
Subproject commit 8da0e30c526ab1c6c825e16546fc5db972c5408d
|
|
@ -1 +1 @@
|
||||||
Subproject commit c39c0696806a0ef09bc90e477ea6b177d2824699
|
Subproject commit f3827a13d12f27e20874df81dc99b55e5dc78244
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9c442bf65b52a4c857cc6e51efe901352e8b6ebf
|
Subproject commit c3f23e5912efff98fc6c8181db579037e5a19a2c
|
|
@ -1 +1 @@
|
||||||
Subproject commit 09f6fd63556a22312af7c5a7e3fa105b26897316
|
Subproject commit 5c0d0961114bcaaf3da52d5918bf0b85ef0e4ce9
|
|
@ -1 +1 @@
|
||||||
Subproject commit 88b79e230005d8301c3ae950abdbf8ad55e37f19
|
Subproject commit c108ba90e6b304515f08fdcff62f428f3f8fbe53
|
|
@ -1 +1 @@
|
||||||
Subproject commit ae60eef4e8413e49fb0dbcae9a343fb479509fa0
|
Subproject commit 0eab8cfeee55cfa3bb893ec31137d3c25b83a1ae
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2c4faa5372d2d8b0c2d16710fe5f93beab1c86af
|
Subproject commit 53c12ddae315731f5cd4d1d71fff57b4836a9c2d
|
Loading…
Reference in New Issue