mirror of https://github.com/vacp2p/nim-libp2p.git
close connections asyncronously
This commit is contained in:
parent
022a248ca3
commit
152c1e3c14
|
@ -7,6 +7,7 @@
|
||||||
## This file may not be copied, modified, or distributed except according to
|
## This file may not be copied, modified, or distributed except according to
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
|
import sequtils
|
||||||
import chronos
|
import chronos
|
||||||
import peerinfo, connection, multiaddress, multicodec
|
import peerinfo, connection, multiaddress, multicodec
|
||||||
|
|
||||||
|
@ -34,8 +35,7 @@ proc newTransport*(t: typedesc[Transport]): t {.gcsafe.} =
|
||||||
method close*(t: Transport) {.base, async, gcsafe.} =
|
method close*(t: Transport) {.base, async, gcsafe.} =
|
||||||
## stop and cleanup the transport
|
## stop and cleanup the transport
|
||||||
## including all outstanding connections
|
## including all outstanding connections
|
||||||
for c in t.connections:
|
await allFutures(t.connections.mapIt(it.connection.close()))
|
||||||
await c.connection.close()
|
|
||||||
|
|
||||||
method listen*(t: Transport,
|
method listen*(t: Transport,
|
||||||
ma: MultiAddress,
|
ma: MultiAddress,
|
||||||
|
|
Loading…
Reference in New Issue