diff --git a/core/txpool/lending_pool.go b/core/txpool/lending_pool.go index 333626c125..2f4bab9a8a 100644 --- a/core/txpool/lending_pool.go +++ b/core/txpool/lending_pool.go @@ -143,7 +143,6 @@ type LendingPool struct { all map[common.Hash]*types.LendingTransaction // All transactions to allow lookups wg sync.WaitGroup // for shutdown sync homestead bool - IsSigner func(address common.Address) bool } // NewLendingPool creates a new transaction pool to gather, sort and filter inbound diff --git a/core/txpool/order_pool.go b/core/txpool/order_pool.go index b946dc2e54..123d36f8bd 100644 --- a/core/txpool/order_pool.go +++ b/core/txpool/order_pool.go @@ -152,7 +152,6 @@ type OrderPool struct { all map[common.Hash]*types.OrderTransaction // All transactions to allow lookups wg sync.WaitGroup // for shutdown sync homestead bool - IsSigner func(address common.Address) bool } // NewOrderPool creates a new transaction pool to gather, sort and filter inbound diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index b893006924..0f7354e9e3 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -289,7 +289,7 @@ type TxPool struct { changesSinceReorg int // A counter for how many drops we've performed in-between reorg. - IsSigner func(address common.Address) bool + isSigner func(address common.Address) bool trc21FeeCapacity map[common.Address]*big.Int } @@ -623,7 +623,7 @@ func (pool *TxPool) validateTxBasics(tx *types.Transaction, local bool) error { MaxSize: txMaxSize, MinTip: pool.gasTip.Load(), NotSigner: func(from common.Address) bool { - return pool.IsSigner != nil && !pool.IsSigner(from) + return pool.IsNotSigner(from) }, } if local { @@ -718,7 +718,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e // already validated from, _ := types.Sender(pool.signer, tx) - if tx.IsSpecialTransaction() && pool.IsSigner != nil && pool.IsSigner(from) && pool.pendingNonces.get(from) == tx.Nonce() { + if tx.IsSpecialTransaction() && pool.IsSigner(from) && pool.pendingNonces.get(from) == tx.Nonce() { return pool.promoteSpecialTx(from, tx, isLocal) } @@ -1707,6 +1707,18 @@ func (pool *TxPool) demoteUnexecutables() { } } +func (pool *TxPool) SetSigner(f func(address common.Address) bool) { + pool.isSigner = f +} + +func (pool *TxPool) IsSigner(addr common.Address) bool { + return pool.isSigner != nil && pool.isSigner(addr) +} + +func (pool *TxPool) IsNotSigner(addr common.Address) bool { + return pool.isSigner != nil && !pool.isSigner(addr) +} + // addressByHeartbeat is an account address tagged with its last activity timestamp. type addressByHeartbeat struct { address common.Address diff --git a/eth/backend.go b/eth/backend.go index ebe31ec139..add16777d9 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -302,7 +302,7 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin log.Error("Cannot get etherbase for append m2 header", "err", err) return fmt.Errorf("etherbase missing: %v", err) } - ok := eth.txPool.IsSigner != nil && eth.txPool.IsSigner(eb) + ok := eth.txPool.IsSigner(eb) if !ok { return nil } @@ -355,9 +355,10 @@ func New(stack *node.Node, config *ethconfig.Config, XDCXServ *XDCx.XDCX, lendin hooks.AttachConsensusV1Hooks(c, eth.blockchain, chainConfig) hooks.AttachConsensusV2Hooks(c, eth.blockchain, chainConfig) - eth.txPool.IsSigner = func(address common.Address) bool { + isSigner := func(address common.Address) bool { return c.IsAuthorisedAddress(eth.blockchain, eth.blockchain.CurrentHeader(), address) } + eth.txPool.SetSigner(isSigner) } // Start the RPC service eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, eth.NetVersion())