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