Skip to content

Commit

Permalink
add mutex for deduplication interval
Browse files Browse the repository at this point in the history
  • Loading branch information
randyahx committed Oct 31, 2023
1 parent 3b6a3e6 commit 7d1601e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions verifier/hash_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,14 @@ func (v *Verifier) preCheck(event *model.Event, currentHeight uint64) error {
if heartbeatInterval == 0 {
panic("heartbeat interval should not zero, potential bug")
}
if event.ChallengerAddress == "" && event.ChallengeId%heartbeatInterval != 0 && event.ChallengeId > v.deduplicationInterval {

v.mtx.Lock()
deduplicationInterval := v.deduplicationInterval
v.mtx.Unlock()

if event.ChallengerAddress == "" && event.ChallengeId%heartbeatInterval != 0 && event.ChallengeId > deduplicationInterval {
found, err := v.dataProvider.IsEventExistsBetween(event.ObjectId, event.SpOperatorAddress,
event.ChallengeId-v.deduplicationInterval, event.ChallengeId-1)
event.ChallengeId-deduplicationInterval, event.ChallengeId-1)
if err != nil {
logging.Logger.Errorf("verifier failed to retrieve information for event %d, err=%+v", event.ChallengeId, err.Error())
return err
Expand Down

0 comments on commit 7d1601e

Please sign in to comment.