Skip to content

Commit

Permalink
refactor: clean up p2pModule#isNonceAlreadyObserved()
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed May 31, 2023
1 parent a1bd6f2 commit afec03c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions p2p/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit afec03c

Please sign in to comment.