mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-27 07:06:42 +00:00
chore(chat2): remove noise, set sender timestamp (#877)
This commit is contained in:
parent
994ac49472
commit
aa1ce4d33f
@ -23,7 +23,7 @@ import libp2p/[switch, # manage transports, a single entry poi
|
||||
muxers/muxer] # define an interface for stream multiplexing, allowing peers to offer many protocols over a single connection
|
||||
import ../../waku/v2/node/[wakunode2, waku_payload],
|
||||
../../waku/v2/node/./dnsdisc/waku_dnsdisc,
|
||||
../../waku/v2/utils/peers,
|
||||
../../waku/v2/utils/[peers,time],
|
||||
../../waku/common/utils/nat,
|
||||
./config_chat2
|
||||
|
||||
@ -216,7 +216,7 @@ proc publish(c: Chat, line: string) =
|
||||
encodedPayload = payload.encode(version, c.node.rng[])
|
||||
if encodedPayload.isOk():
|
||||
var message = WakuMessage(payload: encodedPayload.get(),
|
||||
contentTopic: c.contentTopic, version: version)
|
||||
contentTopic: c.contentTopic, version: version, timestamp: getNanosecondTime(time))
|
||||
when defined(rln):
|
||||
if not isNil(c.node.wakuRlnRelay):
|
||||
# for future version when we support more than one rln protected content topic,
|
||||
@ -238,7 +238,7 @@ proc publish(c: Chat, line: string) =
|
||||
else:
|
||||
# No payload encoding/encryption from Waku
|
||||
var message = WakuMessage(payload: chat2pb.buffer,
|
||||
contentTopic: c.contentTopic, version: 0)
|
||||
contentTopic: c.contentTopic, version: 0, timestamp: getNanosecondTime(time))
|
||||
when defined(rln):
|
||||
if not isNil(c.node.wakuRlnRelay):
|
||||
# for future version when we support more than one rln protected content topic,
|
||||
@ -488,7 +488,8 @@ proc processInput(rfd: AsyncFD, rng: ref BrHmacDrbgContext) {.async.} =
|
||||
let decoded = WakuMessage.init(data)
|
||||
|
||||
if decoded.isOk():
|
||||
chat.printReceivedMessage(decoded.get())
|
||||
if decoded.get().contentTopic == chat.contentTopic:
|
||||
chat.printReceivedMessage(decoded.get())
|
||||
else:
|
||||
trace "Invalid encoded WakuMessage", error = decoded.error
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user