Commit d7dfc942 authored by vicotor's avatar vicotor

fix bug for validator submit transfer

parent 0014e111
......@@ -7,6 +7,7 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"github.com/ethereum/go-ethereum/common/lru"
"github.com/ethereum/go-ethereum/crypto"
log "github.com/sirupsen/logrus"
"strings"
......@@ -33,6 +34,8 @@ type Dao struct {
wg sync.WaitGroup
handleMux sync.Mutex
validatorPk *ecdsa.PrivateKey
failedEvent *lru.Cache[uint, bool]
}
func New(_c *config.Config) (dao *Dao, err error) {
......@@ -41,6 +44,7 @@ func New(_c *config.Config) (dao *Dao, err error) {
chainGroup: make(map[int64]ChainInfo),
syncer: make(map[int64]ChainInterface),
quit: make(chan struct{}),
failedEvent: lru.NewCache[uint, bool](1000),
}
if len(_c.OTPKeyPath) > 0 && len(_c.AesKeyPath) > 0 {
......
......@@ -258,16 +258,19 @@ func (d *Dao) HandleTasks() {
continue
}
if failed, _ := d.failedEvent.Get(event.ID); failed {
if event.UpdatedAt.Compare(event.CreatedAt) > 0 && (int(time.Now().Sub(event.UpdatedAt).Seconds()) < d.c.TaskRetryInterval) {
// skip recently failed tasks.
continue
}
}
if err := d.SubmitInTransfer(event); err != nil {
log.WithError(err).WithFields(log.Fields{
"fromChain": event.FromChain,
"txhash": event.FromChainTxHash,
}).Error("failed to submit in transfer")
d.failedEvent.Add(event.ID, true)
} else {
log.WithFields(log.Fields{
"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