From afec03c51471d5001363eb14f042066f5df0c3d4 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 31 May 2023 11:15:32 +0200 Subject: [PATCH] refactor: clean up `p2pModule#isNonceAlreadyObserved()` --- p2p/module.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/p2p/module.go b/p2p/module.go index fe59daf20..49118f13c 100644 --- a/p2p/module.go +++ b/p2p/module.go @@ -382,15 +382,16 @@ func (m *p2pModule) observeNonce(nonce utils.Nonce) error { // deuper's capacity of recent messages. // DISCUSS(#278): Add more tests to verify this is sufficient for deduping purposes. func (m *p2pModule) isNonceAlreadyObserved(nonce utils.Nonce) bool { - if contains := m.nonceDeduper.Contains(nonce); contains { - m.logger.Debug(). - Uint64("nonce", nonce). - Msgf("message already processed, skipping") - - m.redundantNonceTelemetry(nonce) - return true + if !m.nonceDeduper.Contains(nonce) { + return false } - return false + + m.logger.Debug(). + Uint64("nonce", nonce). + Msgf("message already processed, skipping") + + m.redundantNonceTelemetry(nonce) + return true } func (m *p2pModule) redundantNonceTelemetry(nonce utils.Nonce) {