This commit is contained in:
alex.sharov 2021-08-21 19:13:19 +07:00
parent bc1c7bd91c
commit a12556da38

View File

@ -648,6 +648,8 @@ func onNewBlock(senders *SendersCache, unwindTxs TxSlots, minedTxs []*TxSlot, pr
log.Info("remove mined", "removed", j, "minedTxsLen", len(minedTxs)) 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. // 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 // 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 // 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 // somehow the fact that certain transactions were local, needs to be remembered for some
// time (up to some "immutability threshold"). // time (up to some "immutability threshold").
unsafeAddToPool(senders, unwindTxs, pending, PendingSubPool, func(i *metaTx, sender *senderInfo) { 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) //fmt.Printf("add: %d,%d\n", i.Tx.senderID, i.Tx.nonce)
if _, ok := localsHistory.Get(i.Tx.idHash); ok { if _, ok := localsHistory.Get(i.Tx.idHash); ok {
//TODO: also check if sender is in list of local-senders //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) { for _, sender := range changedSenders {
// TODO: aggregate changed senders before call this func
onSenderChange(sender, protocolBaseFee, pendingBaseFee) onSenderChange(sender, protocolBaseFee, pendingBaseFee)
}) }
pending.EnforceInvariants() pending.EnforceInvariants()
baseFee.EnforceInvariants() baseFee.EnforceInvariants()