import (
"github.com/bytom/errors"
"github.com/bytom/protocol/bc"
- "github.com/bytom/protocol/bc/legacy"
+ "github.com/bytom/protocol/bc/types"
"github.com/bytom/protocol/validation"
)
// ValidateTx validates the given transaction. A cache holds
// per-transaction validation results and is consulted before
// performing full validation.
-func (c *Chain) ValidateTx(tx *legacy.Tx) error {
+func (c *Chain) ValidateTx(tx *types.Tx) error {
newTx := tx.Tx
- block := legacy.MapBlock(c.BestBlock())
+ block := types.MapBlock(c.BestBlock())
if ok := c.txPool.HaveTransaction(&newTx.ID); ok {
return c.txPool.GetErrCache(&newTx.ID)
}
// validate the BVM contract
gasOnlyTx := false
- fee, gasVaild, err := validation.ValidateTx(newTx, block)
+ gasStatus, err := validation.ValidateTx(newTx, block)
if err != nil {
- if !gasVaild {
+ if gasStatus == nil || !gasStatus.GasVaild {
c.txPool.AddErrCache(&newTx.ID, err)
return err
}
gasOnlyTx = true
}
- _, err = c.txPool.AddTransaction(tx, gasOnlyTx, block.BlockHeader.Height, fee)
+ _, err = c.txPool.AddTransaction(tx, gasOnlyTx, block.BlockHeader.Height, gasStatus.BTMValue)
return err
}