diff --git a/eth/p2p.nim b/eth/p2p.nim index d78c570..df0755e 100644 --- a/eth/p2p.nim +++ b/eth/p2p.nim @@ -111,7 +111,7 @@ proc connectToNetwork*(node: EthereumNode, while node.peerPool.connectedNodes.len == 0: trace "Waiting for more peers", peers = node.peerPool.connectedNodes.len - await sleepAsync(500) + await sleepAsync(500.milliseconds) proc stopListening*(node: EthereumNode) = node.listeningServer.stop() diff --git a/eth/p2p/peer_pool.nim b/eth/p2p/peer_pool.nim index ce3f86c..e73339c 100644 --- a/eth/p2p/peer_pool.nim +++ b/eth/p2p/peer_pool.nim @@ -8,7 +8,7 @@ import const lookupInterval = 5 - connectLoopSleepMs = 2000 + connectLoopSleep = chronos.milliseconds(2000) proc newPeerPool*(network: EthereumNode, networkId: uint, keyPair: KeyPair, @@ -179,7 +179,7 @@ proc run(p: PeerPool) {.async.} = if dropConnections: await p.stopAllPeers() - await sleepAsync(connectLoopSleepMs) + await sleepAsync(connectLoopSleep) proc start*(p: PeerPool) = if not p.running: diff --git a/eth/p2p/rlpx_protocols/whisper_protocol.nim b/eth/p2p/rlpx_protocols/whisper_protocol.nim index 0d4a824..c382fed 100644 --- a/eth/p2p/rlpx_protocols/whisper_protocol.nim +++ b/eth/p2p/rlpx_protocols/whisper_protocol.nim @@ -29,8 +29,8 @@ const whisperVersionStr* = $whisperVersion defaultMinPow* = 0.2'f64 defaultMaxMsgSize* = 1024'u32 * 1024'u32 # * 10 # should be no higher than max RLPx size - messageInterval* = 300 ## Interval at which messages are send to peers, in ms - pruneInterval* = 1000 ## Interval at which message queue is pruned, in ms + messageInterval* = chronos.milliseconds(300) ## Interval at which messages are send to peers, in ms + pruneInterval* = chronos.milliseconds(1000) ## Interval at which message queue is pruned, in ms type Hash* = MDigest[256] diff --git a/tests/p2p/test_shh_connect.nim b/tests/p2p/test_shh_connect.nim index 949bf38..592c45b 100644 --- a/tests/p2p/test_shh_connect.nim +++ b/tests/p2p/test_shh_connect.nim @@ -18,7 +18,7 @@ proc resetMessageQueues(nodes: varargs[EthereumNode]) = let bootENode = waitFor setupBootNode() let safeTTL = 5'u32 -let waitInterval = messageInterval + 150 +let waitInterval = messageInterval + 150.milliseconds var node1 = setupTestNode(Whisper) var node2 = setupTestNode(Whisper) @@ -283,7 +283,7 @@ suite "Whisper connections": await sleepAsync(waitInterval) check node1.protocolState(Whisper).queue.items.len == 10 - await sleepAsync(int((lowerTTL+1)*1000)) + await sleepAsync(milliseconds((lowerTTL+1)*1000)) check node1.protocolState(Whisper).queue.items.len == 0 check node2.protocolState(Whisper).queue.items.len == 0