OSDN Git Service

update
authorHAOYUatHZ <haoyu@protonmail.com>
Sun, 16 Jun 2019 06:24:48 +0000 (14:24 +0800)
committerHAOYUatHZ <haoyu@protonmail.com>
Sun, 16 Jun 2019 06:24:48 +0000 (14:24 +0800)
federation/service/warder.go
federation/warder.go

index 7a7a5b3..91f93f7 100644 (file)
@@ -25,3 +25,10 @@ func NewWarder(cfg *config.Warder) *Warder {
 func (w *Warder) RequestSign(destTx interface{}, ormTx *orm.CrossTransaction) (string, error) {
        return "", nil
 }
+
+// NotifySubmission() will notify a remote warder the submission of a destTx,
+// the remote warder will check the tx signs count and set the tx submitted if
+// signs count reach quorum
+func (w *Warder) NotifySubmission(ormTx *orm.CrossTransaction) error {
+       return nil
+}
index fd89d76..a1d6270 100644 (file)
@@ -108,7 +108,7 @@ func (w *warder) processCrossTxRoutine() {
                        }
 
                        if submittedTxID != destTxID {
-                               log.WithFields(log.Fields{"err": err, "cross-chain tx": ormTx, "built tx ID": destTxID, "submittedTx ID": submittedTxID}).Warnln("submitTx ID mismatch")
+                               log.WithFields(log.Fields{"err": err, "cross-chain tx": ormTx, "builtTx ID": destTxID, "submittedTx ID": submittedTxID}).Warnln("submitTx ID mismatch")
                                continue
 
                        }
@@ -214,5 +214,14 @@ func (w *warder) submitTx(destTx interface{}) (string, error) {
 
 // TODO:
 func (w *warder) updateSubmission(tx *orm.CrossTransaction) error {
+       if err := w.db.Where(tx).UpdateColumn(&orm.CrossTransaction{
+               Status: common.CrossTxSubmittedStatus,
+       }).Error; err != nil {
+               return err
+       }
+
+       for _, remote := range w.remotes {
+               remote.NotifySubmission(tx)
+       }
        return nil
 }