@@ -381,28 +381,32 @@ func (s *TxByPrice) Pop() interface{} {
381
381
// transactions in a profit-maximising sorted order, while supporting removing
382
382
// entire batches of transactions for non-executable accounts.
383
383
type 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
386
387
}
387
388
388
389
// NewTransactionsByPriceAndNonce creates a transaction set that can retrieve
389
390
// price sorted transactions in a nonce-honouring way.
390
391
//
391
392
// 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 {
394
395
// Initialize a price based heap with the head transactions
395
396
heads := make (TxByPrice , 0 , len (txs ))
396
- for acc , accTxs := range txs {
397
+ for _ , accTxs := range txs {
397
398
heads = append (heads , accTxs [0 ])
399
+ // Ensure the sender address is from the signer
400
+ acc , _ := Sender (signer , accTxs [0 ])
398
401
txs [acc ] = accTxs [1 :]
399
402
}
400
403
heap .Init (& heads )
401
404
402
405
// Assemble and return the transaction set
403
406
return & TransactionsByPriceAndNonce {
404
- txs : txs ,
405
- heads : heads ,
407
+ txs : txs ,
408
+ heads : heads ,
409
+ signer : signer ,
406
410
}
407
411
}
408
412
@@ -416,9 +420,7 @@ func (t *TransactionsByPriceAndNonce) Peek() *Transaction {
416
420
417
421
// Shift replaces the current best head with the next one from the same account.
418
422
func (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 ])
422
424
if txs , ok := t .txs [acc ]; ok && len (txs ) > 0 {
423
425
t .heads [0 ], t .txs [acc ] = txs [0 ], txs [1 :]
424
426
heap .Fix (& t .heads , 0 )
0 commit comments