28 lines
678 B
Nim
Raw Normal View History

2025-02-10 14:49:30 +01:00
import pkg/chronos
import pkg/questionable/results
import ./config
2025-02-10 15:34:41 +01:00
import ./utils/asyncdataevent
import ./types
2025-02-10 14:49:30 +01:00
type
OnStep = proc(): Future[?!void] {.async: (raises: []), gcsafe.}
2025-02-10 15:34:41 +01:00
DhtNodeCheckEventData* = object
id*: Nid
isOk*: bool
Events* = ref object
nodesFound*: AsyncDataEvent[seq[Nid]]
newNodesDiscovered*: AsyncDataEvent[seq[Nid]]
dhtNodeCheck*: AsyncDataEvent[DhtNodeCheckEventData]
nodesExpired*: AsyncDataEvent[seq[Nid]]
2025-02-11 10:54:58 +01:00
State* = ref object of RootObj
2025-02-10 14:49:30 +01:00
config*: Config
2025-02-10 16:24:54 +01:00
events*: Events
2025-02-10 14:49:30 +01:00
proc whileRunning*(this: State, step: OnStep, delay: Duration) =
discard
#todo: while status == running, step(), asyncsleep duration