mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 00:13:06 +00:00
chore: refactor rm discv5-only (#3453)
This commit is contained in:
parent
0adddb01da
commit
11b44e3e15
@ -26,7 +26,6 @@ logScope:
|
|||||||
type Discv5Conf* {.requiresInit.} = object
|
type Discv5Conf* {.requiresInit.} = object
|
||||||
# TODO: This should probably be an option on the builder
|
# TODO: This should probably be an option on the builder
|
||||||
# But translated to everything else "false" on the config
|
# But translated to everything else "false" on the config
|
||||||
discv5Only*: bool
|
|
||||||
bootstrapNodes*: seq[string]
|
bootstrapNodes*: seq[string]
|
||||||
udpPort*: Port
|
udpPort*: Port
|
||||||
tableIpLimit*: uint
|
tableIpLimit*: uint
|
||||||
|
|||||||
@ -13,7 +13,6 @@ type Discv5ConfBuilder* = object
|
|||||||
bootstrapNodes*: seq[string]
|
bootstrapNodes*: seq[string]
|
||||||
bitsPerHop*: Option[int]
|
bitsPerHop*: Option[int]
|
||||||
bucketIpLimit*: Option[uint]
|
bucketIpLimit*: Option[uint]
|
||||||
discv5Only*: Option[bool]
|
|
||||||
enrAutoUpdate*: Option[bool]
|
enrAutoUpdate*: Option[bool]
|
||||||
tableIpLimit*: Option[uint]
|
tableIpLimit*: Option[uint]
|
||||||
udpPort*: Option[Port]
|
udpPort*: Option[Port]
|
||||||
@ -30,9 +29,6 @@ proc withBitsPerHop*(b: var Discv5ConfBuilder, bitsPerHop: int) =
|
|||||||
proc withBucketIpLimit*(b: var Discv5ConfBuilder, bucketIpLimit: uint) =
|
proc withBucketIpLimit*(b: var Discv5ConfBuilder, bucketIpLimit: uint) =
|
||||||
b.bucketIpLimit = some(bucketIpLimit)
|
b.bucketIpLimit = some(bucketIpLimit)
|
||||||
|
|
||||||
proc withDiscv5Only*(b: var Discv5ConfBuilder, discv5Only: bool) =
|
|
||||||
b.discv5Only = some(discv5Only)
|
|
||||||
|
|
||||||
proc withEnrAutoUpdate*(b: var Discv5ConfBuilder, enrAutoUpdate: bool) =
|
proc withEnrAutoUpdate*(b: var Discv5ConfBuilder, enrAutoUpdate: bool) =
|
||||||
b.enrAutoUpdate = some(enrAutoUpdate)
|
b.enrAutoUpdate = some(enrAutoUpdate)
|
||||||
|
|
||||||
@ -56,7 +52,6 @@ proc build*(b: Discv5ConfBuilder): Result[Option[Discv5Conf], string] =
|
|||||||
bootstrapNodes: b.bootstrapNodes,
|
bootstrapNodes: b.bootstrapNodes,
|
||||||
bitsPerHop: b.bitsPerHop.get(1),
|
bitsPerHop: b.bitsPerHop.get(1),
|
||||||
bucketIpLimit: b.bucketIpLimit.get(2),
|
bucketIpLimit: b.bucketIpLimit.get(2),
|
||||||
discv5Only: b.discv5Only.get(false),
|
|
||||||
enrAutoUpdate: b.enrAutoUpdate.get(true),
|
enrAutoUpdate: b.enrAutoUpdate.get(true),
|
||||||
tableIpLimit: b.tableIpLimit.get(10),
|
tableIpLimit: b.tableIpLimit.get(10),
|
||||||
udpPort: b.udpPort.get(9000.Port),
|
udpPort: b.udpPort.get(9000.Port),
|
||||||
|
|||||||
@ -82,7 +82,6 @@ type WakuConfBuilder* = object
|
|||||||
|
|
||||||
# TODO: move within a relayConf
|
# TODO: move within a relayConf
|
||||||
rendezvous: Option[bool]
|
rendezvous: Option[bool]
|
||||||
discv5Only: Option[bool]
|
|
||||||
|
|
||||||
clusterConf: Option[ClusterConf]
|
clusterConf: Option[ClusterConf]
|
||||||
|
|
||||||
|
|||||||
@ -610,12 +610,6 @@ with the drawback of consuming some more bandwidth.""",
|
|||||||
name: "discv5-bits-per-hop"
|
name: "discv5-bits-per-hop"
|
||||||
.}: int
|
.}: int
|
||||||
|
|
||||||
discv5Only* {.
|
|
||||||
desc: "Disable all protocols other than discv5",
|
|
||||||
defaultValue: false,
|
|
||||||
name: "discv5-only"
|
|
||||||
.}: bool
|
|
||||||
|
|
||||||
## waku peer exchange config
|
## waku peer exchange config
|
||||||
peerExchange* {.
|
peerExchange* {.
|
||||||
desc: "Enable waku peer exchange protocol (responder side): true|false",
|
desc: "Enable waku peer exchange protocol (responder side): true|false",
|
||||||
@ -1021,7 +1015,6 @@ proc toWakuConf*(n: WakuNodeConf): ConfResult[WakuConf] =
|
|||||||
b.discv5Conf.withTableIpLimit(n.discv5TableIpLimit)
|
b.discv5Conf.withTableIpLimit(n.discv5TableIpLimit)
|
||||||
b.discv5Conf.withBucketIpLimit(n.discv5BucketIpLimit)
|
b.discv5Conf.withBucketIpLimit(n.discv5BucketIpLimit)
|
||||||
b.discv5Conf.withBitsPerHop(n.discv5BitsPerHop)
|
b.discv5Conf.withBitsPerHop(n.discv5BitsPerHop)
|
||||||
b.discv5Conf.withDiscv5Only(n.discv5Only)
|
|
||||||
|
|
||||||
b.withPeerExchange(n.peerExchange)
|
b.withPeerExchange(n.peerExchange)
|
||||||
|
|
||||||
|
|||||||
@ -151,10 +151,6 @@ proc setupProtocols(
|
|||||||
## Optionally include persistent message storage.
|
## Optionally include persistent message storage.
|
||||||
## No protocols are started yet.
|
## No protocols are started yet.
|
||||||
|
|
||||||
if conf.discv5Conf.isSome() and conf.discv5Conf.get().discv5Only:
|
|
||||||
notice "Running node only with Discv5, not mounting additional protocols"
|
|
||||||
return ok()
|
|
||||||
|
|
||||||
node.mountMetadata(conf.clusterId).isOkOr:
|
node.mountMetadata(conf.clusterId).isOkOr:
|
||||||
return err("failed to mount waku metadata protocol: " & error)
|
return err("failed to mount waku metadata protocol: " & error)
|
||||||
|
|
||||||
|
|||||||
@ -361,13 +361,12 @@ proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async.} =
|
|||||||
else:
|
else:
|
||||||
waku[].dynamicBootstrapNodes = dynamicBootstrapNodesRes.get()
|
waku[].dynamicBootstrapNodes = dynamicBootstrapNodesRes.get()
|
||||||
|
|
||||||
if conf.discv5Conf.isNone or not conf.discv5Conf.get().discv5Only:
|
(await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr:
|
||||||
(await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr:
|
return err("error while calling startNode: " & $error)
|
||||||
return err("error while calling startNode: " & $error)
|
|
||||||
|
|
||||||
# Update waku data that is set dynamically on node start
|
## Update waku data that is set dynamically on node start
|
||||||
updateWaku(waku).isOkOr:
|
updateWaku(waku).isOkOr:
|
||||||
return err("Error in updateApp: " & $error)
|
return err("Error in updateApp: " & $error)
|
||||||
|
|
||||||
## Discv5
|
## Discv5
|
||||||
if conf.discv5Conf.isSome:
|
if conf.discv5Conf.isSome:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user