don't use MaResult as default in newStandardSwitch (#578)

This commit is contained in:
Dmitriy Ryajov 2021-05-24 16:48:18 -06:00 committed by GitHub
parent 24132d7129
commit 34787728a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

View File

@ -184,26 +184,27 @@ proc build*(b: SwitchBuilder): Switch
return switch return switch
proc newStandardSwitch*(privKey = none(PrivateKey), proc newStandardSwitch*(
address = MultiAddress.init("/ip4/127.0.0.1/tcp/0"), privKey = none(PrivateKey),
secureManagers: openarray[SecureProtocol] = [ address = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
SecureProtocol.Noise, secureManagers: openarray[SecureProtocol] = [
], SecureProtocol.Noise,
transportFlags: set[ServerFlags] = {}, ],
rng = newRng(), transportFlags: set[ServerFlags] = {},
inTimeout: Duration = 5.minutes, rng = newRng(),
outTimeout: Duration = 5.minutes, inTimeout: Duration = 5.minutes,
maxConnections = MaxConnections, outTimeout: Duration = 5.minutes,
maxIn = -1, maxConnections = MaxConnections,
maxOut = -1, maxIn = -1,
maxConnsPerPeer = MaxConnectionsPerPeer): Switch maxOut = -1,
{.raises: [Defect, LPError].} = maxConnsPerPeer = MaxConnectionsPerPeer): Switch
{.raises: [Defect, LPError].} =
if SecureProtocol.Secio in secureManagers: if SecureProtocol.Secio in secureManagers:
quit("Secio is deprecated!") # use of secio is unsafe quit("Secio is deprecated!") # use of secio is unsafe
var b = SwitchBuilder var b = SwitchBuilder
.new() .new()
.withAddress(address.expect("Should have been initialized with default")) .withAddress(address)
.withRng(rng) .withRng(rng)
.withMaxConnections(maxConnections) .withMaxConnections(maxConnections)
.withMaxIn(maxIn) .withMaxIn(maxIn)