Skip to content

Commit f2565ec

Browse files
gzliudanliam.lai
authored andcommitted
core, internal/ethapi: improve function IsSpecialTransaction
1 parent a570142 commit f2565ec

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

core/txpool/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (l *list) Overlaps(tx *types.Transaction) bool {
281281
func (l *list) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Transaction) {
282282
// If there's an older better transaction, abort
283283
old := l.txs.Get(tx.Nonce())
284-
if old != nil && old.IsSpecialTransaction() {
284+
if old.IsSpecialTransaction() {
285285
return false, nil
286286
}
287287
if old != nil {

core/txpool/txpool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
700700
return core.ErrInsufficientFunds
701701
}
702702

703-
if tx.To() == nil || (tx.To() != nil && !tx.IsSpecialTransaction()) {
703+
if !tx.IsSpecialTransaction() {
704704
// Ensure the transaction has more gas than the basic tx fee.
705705
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.eip1559)
706706
if err != nil {
@@ -950,7 +950,7 @@ func (pool *TxPool) promoteSpecialTx(addr common.Address, tx *types.Transaction,
950950
list := pool.pending[addr]
951951

952952
old := list.txs.Get(tx.Nonce())
953-
if old != nil && old.IsSpecialTransaction() {
953+
if old.IsSpecialTransaction() {
954954
return false, ErrDuplicateSpecialTransaction
955955
}
956956
// Otherwise discard any previous transaction and mark this

core/types/transaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func IsSpecialTx(to *common.Address) bool {
487487
}
488488

489489
func (tx *Transaction) IsSpecialTransaction() bool {
490-
return IsSpecialTx(tx.To())
490+
return tx != nil && IsSpecialTx(tx.To())
491491
}
492492

493493
func (tx *Transaction) IsTradingTransaction() bool {

internal/ethapi/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ func (s *PublicTransactionPoolAPI) sign(addr common.Address, tx *types.Transacti
22892289

22902290
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
22912291
func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) {
2292-
if tx.To() != nil && tx.IsSpecialTransaction() {
2292+
if tx.IsSpecialTransaction() {
22932293
return common.Hash{}, errors.New("don't allow transaction sent to BlockSigners & RandomizeSMC smart contract via API")
22942294
}
22952295

0 commit comments

Comments
 (0)