Commit 3baa11b2 authored by vicotor's avatar vicotor

set event validator_status to failure if tx failed.

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