Skip to content

Commit

Permalink
waku factory change to mount circuit hop proto by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Oct 22, 2024
1 parent 399e2f9 commit f7a72cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions waku/factory/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type
switchSslSecureCert: Option[string]
switchSendSignedPeerRecord: Option[bool]
services: seq[Service]
relay: Relay
circuitRelay: Relay

#Rate limit configs for non-relay req-resp protocols
rateLimitSettings: Option[seq[string]]
Expand Down Expand Up @@ -120,8 +120,8 @@ proc withColocationLimit*(builder: var WakuNodeBuilder, colocationLimit: int) =
proc withRateLimit*(builder: var WakuNodeBuilder, limits: seq[string]) =
builder.rateLimitSettings = some(limits)

proc withRelay*(builder: var WakuNodeBuilder, relay: Relay) =
builder.relay = relay
proc withCircuitRelay*(builder: var WakuNodeBuilder, circuitRelay: Relay) =
builder.circuitRelay = circuitRelay

## Waku switch

Expand Down Expand Up @@ -161,6 +161,12 @@ proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
if builder.record.isNone():
return err("node record is required")

let circuitRelay =
if builder.circuitRelay.isNil():
Relay.new()
else:
builder.circuitRelay

var switch: Switch
try:
switch = newWakuSwitch(
Expand All @@ -177,7 +183,7 @@ proc build*(builder: WakuNodeBuilder): Result[WakuNode, string] =
sendSignedPeerRecord = builder.switchSendSignedPeerRecord.get(false),
agentString = builder.switchAgentString,
peerStoreCapacity = builder.peerStorageCapacity,
relay = builder.relay,
circuitRelay = circuitRelay,
)
except CatchableError:
return err("failed to create switch: " & getCurrentExceptionMsg())
Expand Down
4 changes: 2 additions & 2 deletions waku/node/waku_switch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ proc newWakuSwitch*(
agentString = none(string), # defaults to nim-libp2p version
peerStoreCapacity = none(int), # defaults to 1.25 maxConnections
rendezvous: RendezVous = nil,
relay: Relay,
circuitRelay: Relay,
): Switch {.raises: [Defect, IOError, LPError].} =
var b = SwitchBuilder
.new()
Expand All @@ -93,7 +93,7 @@ proc newWakuSwitch*(
.withTcpTransport(transportFlags)
.withNameResolver(nameResolver)
.withSignedPeerRecord(sendSignedPeerRecord)
.withCircuitRelay(relay)
.withCircuitRelay(circuitRelay)
.withAutonat()

if peerStoreCapacity.isSome():
Expand Down

0 comments on commit f7a72cc

Please sign in to comment.