core, internal/ethapi: improve function IsSpecialTransaction

This commit is contained in:
Daniel Liu 2025-02-20 12:48:17 +08:00
parent 4f8d11e11d
commit b60396a233
4 changed files with 5 additions and 5 deletions

View file

@ -281,7 +281,7 @@ func (l *list) Overlaps(tx *types.Transaction) bool {
func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transaction) {
// If there's an older better transaction, abort
old := l.txs.Get(tx.Nonce())
if old != nil && old.IsSpecialTransaction() {
if old.IsSpecialTransaction() {
return false, nil
}
if old != nil {

View file

@ -700,7 +700,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
return core.ErrInsufficientFunds
}
if tx.To() == nil || (tx.To() != nil && !tx.IsSpecialTransaction()) {
if !tx.IsSpecialTransaction() {
// Ensure the transaction has more gas than the basic tx fee.
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.eip1559)
if err != nil {
@ -950,7 +950,7 @@ func (pool *TxPool) promoteSpecialTx(addr common.Address, tx *types.Transaction,
list := pool.pending[addr]
old := list.txs.Get(tx.Nonce())
if old != nil && old.IsSpecialTransaction() {
if old.IsSpecialTransaction() {
return false, ErrDuplicateSpecialTransaction
}
// Otherwise discard any previous transaction and mark this

View file

@ -487,7 +487,7 @@ func IsSpecialTx(to *common.Address) bool {
}
func (tx *Transaction) IsSpecialTransaction() bool {
return IsSpecialTx(tx.To())
return tx != nil && IsSpecialTx(tx.To())
}
func (tx *Transaction) IsTradingTransaction() bool {

View file

@ -2294,7 +2294,7 @@ func (s *PublicTransactionPoolAPI) sign(addr common.Address, tx *types.Transacti
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) {
if tx.To() != nil && tx.IsSpecialTransaction() {
if tx.IsSpecialTransaction() {
return common.Hash{}, errors.New("don't allow transaction sent to BlockSigners & RandomizeSMC smart contract via API")
}