OSDN Git Service

drop the useless tx (#455)
authorPaladz <yzhu101@uottawa.ca>
Wed, 27 Nov 2019 07:59:13 +0000 (15:59 +0800)
committerGitHub <noreply@github.com>
Wed, 27 Nov 2019 07:59:13 +0000 (15:59 +0800)
* drop the useless tx

* fix bug

protocol/txpool.go

index ae237bd..4b47f91 100644 (file)
@@ -216,6 +216,19 @@ func isTransactionZeroOutput(tx *types.Tx) bool {
        return false
 }
 
+func isNoGasStatusFail(tx *types.Tx, statusFail bool) bool {
+       if !statusFail {
+               return false
+       }
+
+       for _, input := range tx.TxData.Inputs {
+               if *consensus.BTMAssetID == input.AssetID() {
+                       return false
+               }
+       }
+       return true
+}
+
 //IsDust checks if a tx has zero output
 func (tp *TxPool) IsDust(tx *types.Tx) bool {
        if ok := isTransactionZeroOutput(tx); ok {
@@ -264,6 +277,11 @@ func (tp *TxPool) ProcessTransaction(tx *types.Tx, statusFail bool, height, fee
                log.WithFields(log.Fields{"module": logModule, "tx_id": tx.ID.String()}).Warn("dust tx")
                return false, nil
        }
+
+       if isNoGasStatusFail(tx, statusFail) {
+               log.WithFields(log.Fields{"module": logModule, "tx_id": tx.ID.String()}).Warn("drop no gas status fail tx")
+               return false, nil
+       }
        return tp.processTransaction(tx, statusFail, height, fee)
 }