mirror of
https://github.com/logos-storage/logos-storage-nim-validator.git
synced 2026-01-09 17:03:05 +00:00
15 lines
472 B
Nim
15 lines
472 B
Nim
|
|
import ../basics
|
||
|
|
import ./address
|
||
|
|
|
||
|
|
type NetworkServer* = distinct StreamServer
|
||
|
|
|
||
|
|
proc open*(_: type NetworkServer): Future[?!NetworkServer] {.async:(raises:[]).} =
|
||
|
|
NetworkServer(createStreamServer(Port(0))).catch()
|
||
|
|
|
||
|
|
proc address*(server: NetworkServer): ?!NetworkAddress =
|
||
|
|
NetworkAddress(StreamServer(server).localAddress()).catch()
|
||
|
|
|
||
|
|
proc close*(server: NetworkServer) {.async:(raises:[]).} =
|
||
|
|
StreamServer(server).close()
|
||
|
|
await noCancel StreamServer(server).join()
|