@@ -381,28 +381,32 @@ func (s *TxByPrice) Pop() interface{} {
381381// transactions in a profit-maximising sorted order, while supporting removing
382382// entire batches of transactions for non-executable accounts.
383383type TransactionsByPriceAndNonce struct {
384- txs map [common.Address ]Transactions // Per account nonce-sorted list of transactions
385- heads TxByPrice // Next transaction for each unique account (price heap)
384+ txs map [common.Address ]Transactions // Per account nonce-sorted list of transactions
385+ heads TxByPrice // Next transaction for each unique account (price heap)
386+ signer Signer // Signer for the set of transactions
386387}
387388
388389// NewTransactionsByPriceAndNonce creates a transaction set that can retrieve
389390// price sorted transactions in a nonce-honouring way.
390391//
391392// Note, the input map is reowned so the caller should not interact any more with
392- // if after providng it to the constructor.
393- func NewTransactionsByPriceAndNonce (txs map [common.Address ]Transactions ) * TransactionsByPriceAndNonce {
393+ // if after providing it to the constructor.
394+ func NewTransactionsByPriceAndNonce (signer Signer , txs map [common.Address ]Transactions ) * TransactionsByPriceAndNonce {
394395 // Initialize a price based heap with the head transactions
395396 heads := make (TxByPrice , 0 , len (txs ))
396- for acc , accTxs := range txs {
397+ for _ , accTxs := range txs {
397398 heads = append (heads , accTxs [0 ])
399+ // Ensure the sender address is from the signer
400+ acc , _ := Sender (signer , accTxs [0 ])
398401 txs [acc ] = accTxs [1 :]
399402 }
400403 heap .Init (& heads )
401404
402405 // Assemble and return the transaction set
403406 return & TransactionsByPriceAndNonce {
404- txs : txs ,
405- heads : heads ,
407+ txs : txs ,
408+ heads : heads ,
409+ signer : signer ,
406410 }
407411}
408412
@@ -416,9 +420,7 @@ func (t *TransactionsByPriceAndNonce) Peek() *Transaction {
416420
417421// Shift replaces the current best head with the next one from the same account.
418422func (t * TransactionsByPriceAndNonce ) Shift () {
419- signer := deriveSigner (t .heads [0 ].data .V )
420- // derive signer but don't cache.
421- acc , _ := Sender (signer , t .heads [0 ]) // we only sort valid txs so this cannot fail
423+ acc , _ := Sender (t .signer , t .heads [0 ])
422424 if txs , ok := t .txs [acc ]; ok && len (txs ) > 0 {
423425 t .heads [0 ], t .txs [acc ] = txs [0 ], txs [1 :]
424426 heap .Fix (& t .heads , 0 )
0 commit comments