Commit 3baa11b2 authored by vicotor's avatar vicotor

set event validator_status to failure if tx failed.

parent f68a1f7b
package dao
import (
"code.wuban.net.cn/movabridge/token-bridge/constant"
dbModel "code.wuban.net.cn/movabridge/token-bridge/model/db"
"gorm.io/gorm"
"gorm.io/gorm/clause"
......@@ -28,7 +29,7 @@ func (d *Dao) SetStorageHeight(key string, intValue int64) (err error) {
func (d *Dao) GetUnprocessedBridgeEvents(limit int, offset int) (events []*dbModel.BridgeEvent, err error) {
err = d.db.Model(&dbModel.BridgeEvent{}).
Where("`from_chain_tx_hash` != '' AND `to_chain_status` < ? AND `validator_status` = ?", 2, 0).
Where("`from_chain_tx_hash` != '' AND `to_chain_status` < ? AND `validator_status` = ?", 2, constant.ValidatorStatusNoPrecess).
Order("created_at ASC").
Limit(limit).
Offset(offset).
......
......@@ -192,8 +192,12 @@ func (d *Dao) SubmitInTransfer(event *dbModel.BridgeEvent) error {
return err
}
if receipt.Status != types.ReceiptStatusSuccessful {
log.WithField("chainId", chain.conf.ChainId).WithField("tx", tx.Hash().Hex()).Error("tx failed")
return errors.New("tx failed")
log.WithFields(log.Fields{
"chainId": chain.conf.ChainId,
"tx": tx.Hash().Hex(),
}).Error("submit in transfer receipt failed")
//log.WithField("chainId", chain.conf.ChainId).WithField("tx", tx.Hash().Hex()).Error("tx failed")
return d.UpdateBridgeValidatorOperation(event, constant.ValidatorStatusFailure)
}
// update validator status.
log.WithFields(log.Fields{
......
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