Commit d7dfc942 authored by vicotor's avatar vicotor

fix bug for validator submit transfer

parent 0014e111
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"fmt" "fmt"
"github.com/ethereum/go-ethereum/common/lru"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"strings" "strings"
...@@ -33,14 +34,17 @@ type Dao struct { ...@@ -33,14 +34,17 @@ type Dao struct {
wg sync.WaitGroup wg sync.WaitGroup
handleMux sync.Mutex handleMux sync.Mutex
validatorPk *ecdsa.PrivateKey validatorPk *ecdsa.PrivateKey
failedEvent *lru.Cache[uint, bool]
} }
func New(_c *config.Config) (dao *Dao, err error) { func New(_c *config.Config) (dao *Dao, err error) {
dao = &Dao{ dao = &Dao{
c: _c, c: _c,
chainGroup: make(map[int64]ChainInfo), chainGroup: make(map[int64]ChainInfo),
syncer: make(map[int64]ChainInterface), syncer: make(map[int64]ChainInterface),
quit: make(chan struct{}), quit: make(chan struct{}),
failedEvent: lru.NewCache[uint, bool](1000),
} }
if len(_c.OTPKeyPath) > 0 && len(_c.AesKeyPath) > 0 { if len(_c.OTPKeyPath) > 0 && len(_c.AesKeyPath) > 0 {
......
...@@ -258,9 +258,11 @@ func (d *Dao) HandleTasks() { ...@@ -258,9 +258,11 @@ func (d *Dao) HandleTasks() {
continue continue
} }
if event.UpdatedAt.Compare(event.CreatedAt) > 0 && (int(time.Now().Sub(event.UpdatedAt).Seconds()) < d.c.TaskRetryInterval) { if failed, _ := d.failedEvent.Get(event.ID); failed {
// skip recently failed tasks. if event.UpdatedAt.Compare(event.CreatedAt) > 0 && (int(time.Now().Sub(event.UpdatedAt).Seconds()) < d.c.TaskRetryInterval) {
continue // skip recently failed tasks.
continue
}
} }
if err := d.SubmitInTransfer(event); err != nil { if err := d.SubmitInTransfer(event); err != nil {
...@@ -268,6 +270,7 @@ func (d *Dao) HandleTasks() { ...@@ -268,6 +270,7 @@ func (d *Dao) HandleTasks() {
"fromChain": event.FromChain, "fromChain": event.FromChain,
"txhash": event.FromChainTxHash, "txhash": event.FromChainTxHash,
}).Error("failed to submit in transfer") }).Error("failed to submit in transfer")
d.failedEvent.Add(event.ID, true)
} else { } else {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"fromChain": event.FromChain, "fromChain": event.FromChain,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment