From a12556da38c436aac6e46ac71b8ef7f291a87ca5 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Sat, 21 Aug 2021 19:13:19 +0700 Subject: [PATCH] save --- txpool/pool.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/txpool/pool.go b/txpool/pool.go index 77a2ada89..4cef9b59b 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -648,6 +648,8 @@ func onNewBlock(senders *SendersCache, unwindTxs TxSlots, minedTxs []*TxSlot, pr log.Info("remove mined", "removed", j, "minedTxsLen", len(minedTxs)) } + changedSenders := map[uint64]*senderInfo{} + // This can be thought of a reverse operation from the one described before. // When a block that was deemed "the best" of its height, is no longer deemed "the best", the // transactions contained in it, are now viable for inclusion in other blocks, and therefore should @@ -658,6 +660,7 @@ func onNewBlock(senders *SendersCache, unwindTxs TxSlots, minedTxs []*TxSlot, pr // somehow the fact that certain transactions were local, needs to be remembered for some // time (up to some "immutability threshold"). unsafeAddToPool(senders, unwindTxs, pending, PendingSubPool, func(i *metaTx, sender *senderInfo) { + changedSenders[i.Tx.senderID] = sender //fmt.Printf("add: %d,%d\n", i.Tx.senderID, i.Tx.nonce) if _, ok := localsHistory.Get(i.Tx.idHash); ok { //TODO: also check if sender is in list of local-senders @@ -681,10 +684,9 @@ func onNewBlock(senders *SendersCache, unwindTxs TxSlots, minedTxs []*TxSlot, pr } }) - senders.forEach(func(sender *senderInfo) { - // TODO: aggregate changed senders before call this func + for _, sender := range changedSenders { onSenderChange(sender, protocolBaseFee, pendingBaseFee) - }) + } pending.EnforceInvariants() baseFee.EnforceInvariants()