mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 16:33:08 +00:00
* properly pass userMessageLimit to OnchainGroupManager * waku.nimble 2.2.4 Nim compiler * rm stew/shims/net import * change ValidIpAddress.init with parseIpAddress * fix serialize for zerokit * group_manager: separate if statements * protocol_types: add encode UInt32 with zeros up to 32 bytes * windows build: skip libunwind build and rm libunwind.a inlcusion step * bump nph to overcome the compilation issues with 2.2.x * bump nim-libp2p to v1.10.1
37 lines
1.2 KiB
Nim
37 lines
1.2 KiB
Nim
import
|
|
chronos,
|
|
chronicles,
|
|
bearssl/rand,
|
|
libp2p/protocols/connectivity/autonat/client,
|
|
libp2p/protocols/connectivity/autonat/service,
|
|
libp2p/protocols/connectivity/autonat/core
|
|
|
|
const AutonatCheckInterval = Opt.some(chronos.seconds(30))
|
|
|
|
proc getAutonatService*(rng: ref HmacDrbgContext): AutonatService =
|
|
## AutonatService request other peers to dial us back
|
|
## flagging us as Reachable or NotReachable.
|
|
## minConfidence is used as threshold to determine the state.
|
|
## If maxQueueSize > numPeersToAsk past samples are considered
|
|
## in the calculation.
|
|
let autonatService = AutonatService.new(
|
|
autonatClient = AutonatClient.new(),
|
|
rng = rng,
|
|
scheduleInterval = AutonatCheckInterval,
|
|
askNewConnectedPeers = false,
|
|
numPeersToAsk = 3,
|
|
maxQueueSize = 3,
|
|
minConfidence = 0.7,
|
|
)
|
|
|
|
proc statusAndConfidenceHandler(
|
|
networkReachability: NetworkReachability, confidence: Opt[float]
|
|
): Future[void] {.gcsafe, async: (raises: [CancelledError]).} =
|
|
if confidence.isSome():
|
|
info "Peer reachability status",
|
|
networkReachability = networkReachability, confidence = confidence.get()
|
|
|
|
autonatService.statusAndConfidenceHandler(statusAndConfidenceHandler)
|
|
|
|
return autonatService
|