Commit c5037ac1 authored by vicotor's avatar vicotor

update code

parent 3d0871f1
......@@ -180,7 +180,7 @@ func (s *Dao) filterTransferIn(chain ChainInterface, txLog types.Log, ctx contex
log.WithField("chain", chain.Name()).WithError(err).Error("parse TransferInExecution log")
return err
}
if err := s.UpdateBridgeResult(ctx, chain.GetChain().ChainId, event.InId.Int64(), TransferChainExecuted); err != nil {
if err := s.UpdateBridgeResult(ctx, chain.GetChain().ChainId, event.InId.Int64(), TransferChainExecuted, txLog.TxHash); err != nil {
log.WithField("chain", chain.Name()).WithFields(log.Fields{
"error": err.Error(),
}).Error("db update transfer in execution event")
......@@ -192,7 +192,7 @@ func (s *Dao) filterTransferIn(chain ChainInterface, txLog types.Log, ctx contex
log.WithField("chain", chain.Name()).WithError(err).Error("parse TransferInExecution log")
return err
}
if err := s.UpdateBridgeResult(ctx, chain.GetChain().ChainId, event.InId.Int64(), TransferChainRejected); err != nil {
if err := s.UpdateBridgeResult(ctx, chain.GetChain().ChainId, event.InId.Int64(), TransferChainRejected, txLog.TxHash); err != nil {
log.WithField("chain", chain.Name()).WithFields(log.Fields{
"error": err.Error(),
}).Error("db update transfer in execution event")
......
......@@ -4,6 +4,7 @@ import (
"code.wuban.net.cn/movabridge/bridge-backend/constant"
dbModel "code.wuban.net.cn/movabridge/bridge-backend/model/db"
"context"
"github.com/ethereum/go-ethereum/common"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
......@@ -114,13 +115,14 @@ func (d *Dao) FillOutTransferEventInfo(ctx context.Context, outEvent *dbModel.Br
return err
}
func (d *Dao) UpdateBridgeResult(ctx context.Context, toChainId int64, inId int64, result constant.TransferStatus) error {
func (d *Dao) UpdateBridgeResult(ctx context.Context, toChainId int64, inId int64, result constant.TransferStatus, txhash common.Hash) error {
collection := d.db.Collection(new(dbModel.BridgeEvent).TableName())
filter := bson.M{"to_chain": toChainId, "in_id": inId}
update := bson.M{
"$set": bson.M{
"to_chain_status": int(result),
"to_chain_tx_hash": txhash.Hex(),
"to_chain_status": int(result),
},
}
opts := options.Update().SetUpsert(true)
......
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