From 34787728a3b1458555b7055d099964800998cd6d Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 24 May 2021 16:48:18 -0600 Subject: [PATCH] don't use MaResult as default in newStandardSwitch (#578) --- libp2p/builders.nim | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libp2p/builders.nim b/libp2p/builders.nim index a9ac32f..3e14189 100644 --- a/libp2p/builders.nim +++ b/libp2p/builders.nim @@ -184,26 +184,27 @@ proc build*(b: SwitchBuilder): Switch return switch -proc newStandardSwitch*(privKey = none(PrivateKey), - address = MultiAddress.init("/ip4/127.0.0.1/tcp/0"), - secureManagers: openarray[SecureProtocol] = [ - SecureProtocol.Noise, - ], - transportFlags: set[ServerFlags] = {}, - rng = newRng(), - inTimeout: Duration = 5.minutes, - outTimeout: Duration = 5.minutes, - maxConnections = MaxConnections, - maxIn = -1, - maxOut = -1, - maxConnsPerPeer = MaxConnectionsPerPeer): Switch - {.raises: [Defect, LPError].} = +proc newStandardSwitch*( + privKey = none(PrivateKey), + address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(), + secureManagers: openarray[SecureProtocol] = [ + SecureProtocol.Noise, + ], + transportFlags: set[ServerFlags] = {}, + rng = newRng(), + inTimeout: Duration = 5.minutes, + outTimeout: Duration = 5.minutes, + maxConnections = MaxConnections, + maxIn = -1, + maxOut = -1, + maxConnsPerPeer = MaxConnectionsPerPeer): Switch + {.raises: [Defect, LPError].} = if SecureProtocol.Secio in secureManagers: quit("Secio is deprecated!") # use of secio is unsafe var b = SwitchBuilder .new() - .withAddress(address.expect("Should have been initialized with default")) + .withAddress(address) .withRng(rng) .withMaxConnections(maxConnections) .withMaxIn(maxIn)