OSDN Git Service

fix review test_crossin
authormars <mars@bytom.io>
Thu, 20 Jun 2019 08:40:49 +0000 (16:40 +0800)
committermars <mars@bytom.io>
Thu, 20 Jun 2019 08:40:49 +0000 (16:40 +0800)
blockchain/txbuilder/finalize.go
protocol/txpool.go

index bd43f14..f701548 100644 (file)
@@ -153,15 +153,14 @@ func CalculateTxFee(tx *types.Tx) (fee uint64) {
 }
 
 func checkGasInputIDs(tx *types.Tx) error {
-       crossChainInputNum := 0
        for _, inp := range tx.Inputs {
                switch inp.InputType() {
                case types.CrossChainInputType:
-                       crossChainInputNum++
+                       return nil
                }
        }
 
-       if crossChainInputNum != len(tx.Inputs) && len(tx.GasInputIDs) == 0 {
+       if len(tx.GasInputIDs) == 0 {
                return ErrNoGasInput
        }
        return nil
index e55c2a2..32d3f6d 100644 (file)
@@ -193,19 +193,16 @@ func (tp *TxPool) HaveTransaction(txHash *bc.Hash) bool {
 }
 
 func isTransactionNoBtmInput(tx *types.Tx) bool {
-       crossChainInputNum := 0
        for _, input := range tx.TxData.Inputs {
-               if input.AssetID() == *consensus.BTMAssetID {
-                       return false
-               }
                switch input.InputType() {
                case types.CrossChainInputType:
-                       crossChainInputNum++
+                       return false
+               }
+               if input.AssetID() == *consensus.BTMAssetID {
+                       return false
                }
        }
-       if crossChainInputNum == len(tx.TxData.Inputs) {
-               return false
-       }
+
        return true
 }