From 2dcccf19b298d434be0ffc96a65b6c141300aaea Mon Sep 17 00:00:00 2001 From: kdeme Date: Tue, 3 Dec 2019 16:49:20 +0100 Subject: [PATCH] Do not send empty messages packets at interval --- eth/p2p/rlpx_protocols/waku_protocol.nim | 9 +++++---- eth/p2p/rlpx_protocols/whisper_protocol.nim | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/eth/p2p/rlpx_protocols/waku_protocol.nim b/eth/p2p/rlpx_protocols/waku_protocol.nim index 99c88c5..b8630be 100644 --- a/eth/p2p/rlpx_protocols/waku_protocol.nim +++ b/eth/p2p/rlpx_protocols/waku_protocol.nim @@ -270,10 +270,11 @@ proc processQueue(peer: Peer) = envelopes.add(message.env) wakuPeer.received.incl(message) - trace "Sending envelopes", amount=envelopes.len - # Ignore failure of sending messages, this could occur when the connection - # gets dropped - traceAsyncErrors peer.messages(envelopes) + if envelopes.len() > 0: + trace "Sending envelopes", amount=envelopes.len + # Ignore failure of sending messages, this could occur when the connection + # gets dropped + traceAsyncErrors peer.messages(envelopes) proc run(peer: Peer) {.async.} = while peer.connectionState notin {Disconnecting, Disconnected}: diff --git a/eth/p2p/rlpx_protocols/whisper_protocol.nim b/eth/p2p/rlpx_protocols/whisper_protocol.nim index d92919d..72026ef 100644 --- a/eth/p2p/rlpx_protocols/whisper_protocol.nim +++ b/eth/p2p/rlpx_protocols/whisper_protocol.nim @@ -265,10 +265,11 @@ proc processQueue(peer: Peer) = envelopes.add(message.env) whisperPeer.received.incl(message) - trace "Sending envelopes", amount=envelopes.len - # Ignore failure of sending messages, this could occur when the connection - # gets dropped - traceAsyncErrors peer.messages(envelopes) + if envelopes.len() > 0: + trace "Sending envelopes", amount=envelopes.len + # Ignore failure of sending messages, this could occur when the connection + # gets dropped + traceAsyncErrors peer.messages(envelopes) proc run(peer: Peer) {.async.} = while peer.connectionState notin {Disconnecting, Disconnected}: