Skip to content

Commit

Permalink
forcing nonce value to wrap around once limit is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
stubbsta committed Jun 5, 2024
1 parent 4b60735 commit 19a72c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions waku/waku_api/rest/relay/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ proc installRelayApiHandlers*(
if not node.wakuRlnRelay.isNil():
# append the proof to the message

node.wakuRlnRelay.unsafeAppendRLNProof(message, float64(getTime().toUnix())).isOkOr:
node.wakuRlnRelay.appendRLNProof(message, float64(getTime().toUnix())).isOkOr:
return RestApiResponse.internalServerError(
"Failed to publish: error appending RLN proof to message: " & $error
)
Expand Down Expand Up @@ -267,7 +267,7 @@ proc installRelayApiHandlers*(

# if RLN is mounted, append the proof to the message
if not node.wakuRlnRelay.isNil():
node.wakuRlnRelay.unsafeAppendRLNProof(message, float64(getTime().toUnix())).isOkOr:
node.wakuRlnRelay.appendRLNProof(message, float64(getTime().toUnix())).isOkOr:
return RestApiResponse.internalServerError(
"Failed to publish: error appending RLN proof to message: " & $error
)
Expand Down
7 changes: 4 additions & 3 deletions waku/waku_rln_relay/nonce_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ when (NimMajor, NimMinor) < (1, 4):
else:
{.push raises: [].}

import chronos, stew/results, times
import chronos, chronicles, stew/results, times
import ./constants

export chronos, times, results, constants
Expand Down Expand Up @@ -48,8 +48,9 @@ proc getNonce*(n: NonceManager): NonceManagerResult[Nonce] =
n.nextNonce = retNonce + 1
n.lastNonceTime = now

# This is commented out only for testing purposes
# if retNonce >= n.nonceLimit:
# This is modified for testing purposes, once the limit is reached the nonce value is reset to 0
if retNonce >= n.nonceLimit:
retNonce = 0
# return err(
# NonceManagerError(
# kind: NonceLimitReached,
Expand Down

0 comments on commit 19a72c0

Please sign in to comment.