import (
log "github.com/sirupsen/logrus"
+
"github.com/vapor/errors"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
return false, c.txPool.GetErrCache(&tx.ID)
}
- if ok := c.txPool.IsWithdrawSpent(tx); ok {
- log.WithFields(log.Fields{"module": "ValidateTx", "error": "Cliam transactions already exist in the trading pool"}).Error("chain error")
- return false, errors.New("Cliam transactions already exist in the trading pool")
+ if c.txPool.IsDust(tx) {
+ c.txPool.AddErrCache(&tx.ID, ErrDustTx)
+ return false, ErrDustTx
}
bh := c.BestBlockHeader()
- block := types.MapBlock(&types.Block{BlockHeader: *bh})
- gasStatus, err := validation.ValidateTx(tx.Tx, block)
- if gasStatus.GasValid == false {
+ gasStatus, err := validation.ValidateTx(tx.Tx, types.MapBlock(&types.Block{BlockHeader: *bh}))
+ if !gasStatus.GasValid {
c.txPool.AddErrCache(&tx.ID, err)
return false, err
}
if err != nil {
- log.WithFields(log.Fields{"tx_id": tx.Tx.ID.String(), "error": err}).Info("transaction status fail")
+ log.WithFields(log.Fields{"module": logModule, "tx_id": tx.Tx.ID.String(), "error": err}).Info("transaction status fail")
}
- return c.txPool.ProcessTransaction(tx, err != nil, block.BlockHeader.Height, gasStatus.BTMValue)
+ return c.txPool.ProcessTransaction(tx, err != nil, bh.Height, gasStatus.BTMValue)
}