浏览代码

core/types: avoid duplicating transactions on changing signer (#16435)

kimmylin 7 年之前
父节点
当前提交
86be91b3e2
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      core/types/transaction.go

+ 4 - 1
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)