Skip to content

Commit

Permalink
fix: processing pending task only when backoff time expires (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
minh-bq authored Jul 28, 2023
1 parent e5a7f57 commit 1ef9f11
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stores/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stores

import (
"fmt"
"time"

"github.com/axieinfinity/bridge-v2/models"
"gorm.io/gorm"
Expand Down Expand Up @@ -41,6 +42,7 @@ func (t *taskStore) GetTasks(chain, status string, limit, retrySeconds int, befo
// also apply exponential at created_time
var tasks []*models.Task
db := t.Model(&models.Task{}).Where("chain_id = ? AND status = ?", chain, status)
db = db.Where("created_at + POWER(2, retries) * ? <= ?", retrySeconds, time.Now().Unix())
if before > 0 {
db = db.Where("tx_created_at <= ?", before)
}
Expand Down

0 comments on commit 1ef9f11

Please sign in to comment.