builder: add multiple local address support (#591)
This commit is contained in:
parent
b63e064b4a
commit
bee91538ef
|
@ -36,7 +36,7 @@ type
|
|||
|
||||
SwitchBuilder* = ref object
|
||||
privKey: Option[PrivateKey]
|
||||
address: MultiAddress
|
||||
addresses: seq[MultiAddress]
|
||||
secureManagers: seq[SecureProtocol]
|
||||
mplexOpts: MplexOpts
|
||||
tcpTransportOpts: TcpTransportOpts
|
||||
|
@ -56,7 +56,7 @@ proc new*(T: type[SwitchBuilder]): T =
|
|||
|
||||
SwitchBuilder(
|
||||
privKey: none(PrivateKey),
|
||||
address: address,
|
||||
addresses: @[address],
|
||||
secureManagers: @[],
|
||||
tcpTransportOpts: TcpTransportOpts(),
|
||||
maxConnections: MaxConnections,
|
||||
|
@ -71,9 +71,14 @@ proc withPrivateKey*(b: SwitchBuilder, privateKey: PrivateKey): SwitchBuilder =
|
|||
b
|
||||
|
||||
proc withAddress*(b: SwitchBuilder, address: MultiAddress): SwitchBuilder =
|
||||
b.address = address
|
||||
b.addresses = @[address]
|
||||
b
|
||||
|
||||
proc withAddresses*(b: SwitchBuilder, addresses: seq[MultiAddress]): SwitchBuilder =
|
||||
b.addresses = addresses
|
||||
b
|
||||
|
||||
|
||||
proc withMplex*(b: SwitchBuilder, inTimeout = 5.minutes, outTimeout = 5.minutes): SwitchBuilder =
|
||||
proc newMuxer(conn: Connection): Muxer =
|
||||
Mplex.init(
|
||||
|
@ -143,7 +148,7 @@ proc build*(b: SwitchBuilder): Switch
|
|||
let
|
||||
peerInfo = PeerInfo.init(
|
||||
seckey,
|
||||
[b.address],
|
||||
b.addresses,
|
||||
protoVersion = b.protoVersion,
|
||||
agentVersion = b.agentVersion)
|
||||
|
||||
|
|
Loading…
Reference in New Issue