From a0a20f3207d5faa79c0c6a6e2be1084adde8bba2 Mon Sep 17 00:00:00 2001 From: kimmylin <30611210+kimmylin@users.noreply.github.com> Date: Tue, 24 Apr 2018 15:39:03 +0800 Subject: [PATCH] core/types: avoid duplicating transactions on changing signer (#16435) --- core/types/transaction.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/types/transaction.go b/core/types/transaction.go index 26b9845776fb..14be021490cb 100755 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -339,11 +339,14 @@ type TransactionsByPriceAndNonce struct { func NewTransactionsByPriceAndNonce(signer Signer, txs map[common.Address]Transactions) *TransactionsByPriceAndNonce { // Initialize a price based heap with the head transactions heads := make(TxByPrice, 0, len(txs)) - for _, accTxs := range txs { + for from, accTxs := range txs { heads = append(heads, accTxs[0]) // Ensure the sender address is from the signer acc, _ := Sender(signer, accTxs[0]) txs[acc] = accTxs[1:] + if from != acc { + delete(txs, from) + } } heap.Init(&heads)