mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-26 10:55:41 +00:00
Merge pull request #509 from status-im/state
small NimbusState refactoring
This commit is contained in:
commit
bd4069d5ca
@ -27,7 +27,7 @@ const
|
|||||||
|
|
||||||
type
|
type
|
||||||
NimbusState = enum
|
NimbusState = enum
|
||||||
Starting, Running, Stopping, Stopped
|
Starting, Running, Stopping
|
||||||
|
|
||||||
NimbusNode = ref object
|
NimbusNode = ref object
|
||||||
rpcServer*: RpcHttpServer
|
rpcServer*: RpcHttpServer
|
||||||
@ -36,7 +36,6 @@ type
|
|||||||
|
|
||||||
proc start(nimbus: NimbusNode) =
|
proc start(nimbus: NimbusNode) =
|
||||||
var conf = getConfiguration()
|
var conf = getConfiguration()
|
||||||
nimbus.state = Starting
|
|
||||||
|
|
||||||
## logging
|
## logging
|
||||||
setLogLevel(conf.debug.logLevel)
|
setLogLevel(conf.debug.logLevel)
|
||||||
@ -160,8 +159,7 @@ proc stop*(nimbus: NimbusNode) {.async, gcsafe.} =
|
|||||||
nimbus.rpcServer.stop()
|
nimbus.rpcServer.stop()
|
||||||
|
|
||||||
proc process*(nimbus: NimbusNode) =
|
proc process*(nimbus: NimbusNode) =
|
||||||
if nimbus.state == Running:
|
# Main event loop
|
||||||
# Main loop
|
|
||||||
while nimbus.state == Running:
|
while nimbus.state == Running:
|
||||||
try:
|
try:
|
||||||
poll()
|
poll()
|
||||||
@ -172,7 +170,7 @@ proc process*(nimbus: NimbusNode) =
|
|||||||
waitFor nimbus.stop()
|
waitFor nimbus.stop()
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var nimbus = NimbusNode()
|
var nimbus = NimbusNode(state: Starting)
|
||||||
|
|
||||||
## Ctrl+C handling
|
## Ctrl+C handling
|
||||||
proc controlCHandler() {.noconv.} =
|
proc controlCHandler() {.noconv.} =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user