mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-23 13:03:11 +00:00
refactor(node-info): source MaxMessageSize from node config
Read the reported value from `conf.maxMessageSizeBytes` instead of the mounted relay. The relay only holds a copy of the configured value and is absent on relay-disabled (light) nodes, which would report an empty string. Sourcing from the config makes the item always available and reflects the node's configured limit directly. WakuStateInfo now holds the WakuConf it reports on; init takes it as an argument. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0b0368a305
commit
0a20894909
@ -5,13 +5,9 @@
|
||||
## accessible through the debug API.
|
||||
|
||||
import std/[tables, sequtils, strutils]
|
||||
import
|
||||
metrics,
|
||||
eth/p2p/discoveryv5/enr,
|
||||
libp2p/peerid,
|
||||
libp2p/protocols/pubsub/gossipsub,
|
||||
stew/byteutils
|
||||
import metrics, eth/p2p/discoveryv5/enr, libp2p/peerid, stew/byteutils
|
||||
import logos_delivery/waku/[waku_node, net/bound_ports]
|
||||
import logos_delivery/waku/factory/waku_conf
|
||||
|
||||
type
|
||||
NodeInfoId* {.pure.} = enum
|
||||
@ -26,6 +22,7 @@ type
|
||||
|
||||
WakuStateInfo* {.requiresInit.} = object
|
||||
node: WakuNode
|
||||
conf: WakuConf
|
||||
|
||||
proc getAllPossibleInfoItemIds*(self: WakuStateInfo): seq[NodeInfoId] =
|
||||
## Returns all possible options that can be queried to learn about the node's information.
|
||||
@ -59,13 +56,10 @@ proc getNodeInfoItem*(self: WakuStateInfo, infoItemId: NodeInfoId): string =
|
||||
return ""
|
||||
return self.node.wakuMix.pubKey.to0xHex()
|
||||
of NodeInfoId.MaxMessageSize:
|
||||
## Max message size (in bytes) accepted by the relay protocol.
|
||||
## Empty when the relay protocol is not mounted on this node.
|
||||
if self.node.wakuRelay.isNil():
|
||||
return ""
|
||||
return $self.node.wakuRelay.maxMessageSize
|
||||
## Configured max message size (in bytes) for this node.
|
||||
return $self.conf.maxMessageSizeBytes
|
||||
else:
|
||||
return "unknown info item id"
|
||||
|
||||
proc init*(T: typedesc[WakuStateInfo], node: WakuNode): T =
|
||||
return WakuStateInfo(node: node)
|
||||
proc init*(T: typedesc[WakuStateInfo], node: WakuNode, conf: WakuConf): T =
|
||||
return WakuStateInfo(node: node, conf: conf)
|
||||
|
||||
@ -235,7 +235,7 @@ proc new*(
|
||||
return err("Failed setting up app callbacks: " & $error)
|
||||
|
||||
var waku = Waku(
|
||||
stateInfo: WakuStateInfo.init(node),
|
||||
stateInfo: WakuStateInfo.init(node, wakuConf),
|
||||
conf: wakuConf,
|
||||
rng: rng,
|
||||
key: wakuConf.nodeKey,
|
||||
|
||||
@ -235,7 +235,9 @@ suite "Health Monitor - events":
|
||||
# `waku.node` is read on the messaging path; `conf`/`stateInfo` are supplied
|
||||
# solely to satisfy Waku's {.requiresInit.} fields.
|
||||
let waku = Waku(
|
||||
node: nodeA, conf: defaultTestWakuConf(), stateInfo: WakuStateInfo.init(nodeA)
|
||||
node: nodeA,
|
||||
conf: defaultTestWakuConf(),
|
||||
stateInfo: WakuStateInfo.init(nodeA, defaultTestWakuConf()),
|
||||
)
|
||||
let ds = MessagingClient
|
||||
.new(MessagingClientConf(useP2PReliability: false), waku)
|
||||
@ -346,7 +348,9 @@ suite "Health Monitor - events":
|
||||
# `waku.node` is read on the messaging path; `conf`/`stateInfo` are supplied
|
||||
# solely to satisfy Waku's {.requiresInit.} fields.
|
||||
let waku = Waku(
|
||||
node: nodeA, conf: defaultTestWakuConf(), stateInfo: WakuStateInfo.init(nodeA)
|
||||
node: nodeA,
|
||||
conf: defaultTestWakuConf(),
|
||||
stateInfo: WakuStateInfo.init(nodeA, defaultTestWakuConf()),
|
||||
)
|
||||
let ds = MessagingClient
|
||||
.new(MessagingClientConf(useP2PReliability: false), waku)
|
||||
|
||||
@ -33,12 +33,6 @@ suite "Wakunode2 - Waku":
|
||||
|
||||
let waku = (waitFor Waku.new(conf)).valueOr:
|
||||
raiseAssert error
|
||||
defer:
|
||||
(waitFor waku.stop()).isOkOr:
|
||||
raiseAssert error
|
||||
|
||||
(waitFor waku.start()).isOkOr:
|
||||
raiseAssert error
|
||||
|
||||
## When
|
||||
let maxMessageSize = waku.stateInfo.getNodeInfoItem(NodeInfoId.MaxMessageSize)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user