Skip to content

Commit

Permalink
fix wrong if
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Sep 20, 2023
1 parent 5976a03 commit 30c351e
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ func (r *logRecoverer) populatePending(f upkeepFilter, filteredLogs []logpoller.
}
// r.lggr.Debugw("adding a payload to pending", "payload", payload)
if err := r.addPending(payload); err != nil {
errs = append(errs, err)
} else {
r.visited[wid] = visitedRecord{
visitedAt: time.Now(),
payload: payload,
}
} else {
errs = append(errs, err)
}
}
return len(r.pending) - pendingSizeBefore, alreadyPending, len(errs) == 0
Expand Down Expand Up @@ -632,7 +632,7 @@ func (r *logRecoverer) tryExpire(ctx context.Context, ids ...string) error {
removed++
continue
}
if err := r.addPending(rec.payload); err != nil {
if err := r.addPending(rec.payload); err == nil {
rec.visitedAt = time.Now()
r.visited[ids[i]] = rec
}
Expand All @@ -655,17 +655,16 @@ func (r *logRecoverer) addPending(payload ocr2keepers.UpkeepPayload) error {
var exist bool
pending := r.pending
upkeepPayloads := 0
upkeepID := payload.UpkeepID
for _, p := range pending {
if bytes.Equal(p.UpkeepID[:], upkeepID[:]) {
if bytes.Equal(p.UpkeepID[:], payload.UpkeepID[:]) {
upkeepPayloads++
}
if p.WorkID == payload.WorkID {
exist = true
}
}
if upkeepPayloads >= maxPendingPayloadsPerUpkeep {
return fmt.Errorf("upkeep %v has too many payloads in pending queue", upkeepID)
return fmt.Errorf("upkeep %v has too many payloads in pending queue", payload.UpkeepID)
}
if !exist {
r.pending = append(pending, payload)
Expand Down

0 comments on commit 30c351e

Please sign in to comment.