From e1ca47ce33478dabfa18ae0b01c1aa6a52f4f6cf Mon Sep 17 00:00:00 2001 From: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Date: Wed, 15 Jul 2026 05:44:40 +0200 Subject: [PATCH] refactor(apps): adopt WakuEnvelope in relay handlers and message-path bench chat2 and networkmonitor relay handlers take the envelope; the micro/macro benchmark's app handlers follow the new signature (paced/windowed publishing and counters unchanged). Co-Authored-By: Claude Fable 5 --- apps/benchmarks/message_path_bench.nim | 4 ++-- apps/chat2/chat2.nim | 4 +++- apps/networkmonitor/networkmonitor.nim | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/benchmarks/message_path_bench.nim b/apps/benchmarks/message_path_bench.nim index af9333166..e413e44bf 100644 --- a/apps/benchmarks/message_path_bench.nim +++ b/apps/benchmarks/message_path_bench.nim @@ -211,7 +211,7 @@ proc emit(res: ScenarioResult) = # Node setup # --------------------------------------------------------------------------- -proc dummyHandler(topic: PubsubTopic, msg: WakuMessage) {.async, gcsafe.} = +proc dummyHandler(envelope: WakuEnvelope) {.async, gcsafe.} = discard proc buildIngestNode( @@ -304,7 +304,7 @@ proc runMacro(shard: PubsubTopic, work: Workload): Future[ScenarioResult] {.asyn times: newSeqOfCap[MonoTime](work.msgs.len), ) - proc countingHandler(topic: PubsubTopic, msg: WakuMessage) {.async, gcsafe.} = + proc countingHandler(envelope: WakuEnvelope) {.async, gcsafe.} = arrivals.times.add(getMonoTime()) arrivals.count += 1 if arrivals.count >= arrivals.target: diff --git a/apps/chat2/chat2.nim b/apps/chat2/chat2.nim index 647667b0c..38c0a9740 100644 --- a/apps/chat2/chat2.nim +++ b/apps/chat2/chat2.nim @@ -508,7 +508,9 @@ proc processInput(rfd: AsyncFD, rng: crypto.Rng) {.async.} = # Subscribe to a topic, if relay is mounted if conf.relay: - proc handler(topic: PubsubTopic, msg: WakuMessage): Future[void] {.async, gcsafe.} = + proc handler(envelope: WakuEnvelope): Future[void] {.async, gcsafe.} = + let topic = envelope.pubsubTopic + let msg = envelope.msg trace "Hit subscribe handler", topic if msg.contentTopic == chat.contentTopic: diff --git a/apps/networkmonitor/networkmonitor.nim b/apps/networkmonitor/networkmonitor.nim index a23c778ef..7cc3bbcdc 100644 --- a/apps/networkmonitor/networkmonitor.nim +++ b/apps/networkmonitor/networkmonitor.nim @@ -518,9 +518,9 @@ proc subscribeAndHandleMessages( msgPerContentTopic: ContentTopicMessageTableRef, ) = # handle function - proc handler( - pubsubTopic: PubsubTopic, msg: WakuMessage - ): Future[void] {.async, gcsafe.} = + proc handler(envelope: WakuEnvelope): Future[void] {.async, gcsafe.} = + let pubsubTopic = envelope.pubsubTopic + let msg = envelope.msg trace "rx message", pubsubTopic = pubsubTopic, contentTopic = msg.contentTopic # If we reach a table limit size, remove c topics with the least messages.