Add Yamux experimental support (#5080)

This commit is contained in:
Tanguy 2023-06-23 09:16:30 +02:00 committed by GitHub
parent 8a853fc4e4
commit 11d18acfeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -305,6 +305,12 @@ type
defaultValue: false
name: "enr-auto-update" .}: bool
enableYamux* {.
hidden
desc: "Enable the Yamux multiplexer"
defaultValue: false
name: "enable-yamux" .}: bool
weakSubjectivityCheckpoint* {.
desc: "Weak subjectivity checkpoint in the format block_root:epoch_number"
name: "weak-subjectivity-checkpoint" .}: Option[Checkpoint]

View File

@ -102,6 +102,12 @@ type LightClientConf* = object
defaultValue: false
name: "enr-auto-update" .}: bool
enableYamux* {.
hidden
desc: "Enable the Yamux multiplexer"
defaultValue: false
name: "enable-yamux" .}: bool
agentString* {.
defaultValue: "nimbus",
desc: "Node agent string which is used as identifier in network"

View File

@ -2271,8 +2271,14 @@ func gossipId(
proc newBeaconSwitch(config: BeaconNodeConf | LightClientConf,
seckey: PrivateKey, address: MultiAddress,
rng: ref HmacDrbgContext): Switch {.raises: [Defect, CatchableError].} =
SwitchBuilder
.new()
var sb =
if config.enableYamux:
SwitchBuilder.new().withYamux()
else:
SwitchBuilder.new()
# Order of multiplexers matters, the first will be default
sb
.withPrivateKey(seckey)
.withAddress(address)
.withRng(rng)