OSDN Git Service

fix: add CrossChainInput in NewTxVMContext (#124)
[bytom/vapor.git] / protocol / txpool.go
index 7d6bf9f..957ab6a 100644 (file)
@@ -277,12 +277,21 @@ func (tp *TxPool) addTransaction(txD *TxDesc) error {
        txD.Added = time.Now()
        tp.pool[tx.ID] = txD
        for _, id := range tx.ResultIds {
-               output, err := tx.IntraChainOutput(*id)
+               var assetID bc.AssetID
+               outputEntry, err := tx.Entry(*id)
                if err != nil {
-                       // error due to it's a retirement, utxo doesn't care this output type so skip it
+                       return err
+               }
+               switch output := outputEntry.(type) {
+               case *bc.IntraChainOutput:
+                       assetID = *output.Source.Value.AssetId
+               case *bc.VoteOutput:
+                       assetID = *output.Source.Value.AssetId
+               default:
                        continue
                }
-               if !txD.StatusFail || *output.Source.Value.AssetId == *consensus.BTMAssetID {
+
+               if !txD.StatusFail || assetID == *consensus.BTMAssetID {
                        tp.utxo[*id] = tx
                }
        }