logos-messaging-nim/waku/net/bound_ports.nim
Fabiana Cecin 2dc8176407
Fixes from Ivan's review
* fix node info to use announcedAddresses again
* expose ports via Debug API ("MyBoundPorts")
* builders default to port 0 in discv5/metrics/p2pTcp
* add waku/net/bound_ports.nim
* move auto_port and net_config to waku/net/
* extract port-0 retry loop to tryWithAutoPort[T]
* misc refactors and fixes
2026-04-24 21:28:58 -03:00

28 lines
657 B
Nim

{.push raises: [].}
import std/[json, options]
type BoundPorts* {.requiresInit.} = object
## Set by the factory once each service has bound to a port.
tcp*: Option[uint16]
webSocket*: Option[uint16]
rest*: Option[uint16]
discv5Udp*: Option[uint16]
metrics*: Option[uint16]
proc init*(T: type BoundPorts): BoundPorts =
BoundPorts(
tcp: none(uint16),
webSocket: none(uint16),
rest: none(uint16),
discv5Udp: none(uint16),
metrics: none(uint16),
)
proc toJsonString*(p: BoundPorts): string =
var obj = newJObject()
for name, value in fieldPairs(p):
if value.isSome():
obj[name] = %value.get()
return $obj