From 92740a39359d6f2eeccc53bd328f199f38bb8052 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Fri, 27 Aug 2021 17:17:10 +0700 Subject: [PATCH] add state check assert routine --- txpool/pool.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/txpool/pool.go b/txpool/pool.go index f204c7c2a..c951418dd 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -569,7 +569,7 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce, sendersWithoutTransa if sc.commitID-binary.BigEndian.Uint64(k) < 5 { break } - fmt.Printf("del:%d\n", binary.BigEndian.Uint64(k)) + fmt.Printf("del:%d,%d\n", binary.BigEndian.Uint64(k), sc.commitID) for i := 0; i < len(v); i += 8 { senderID := binary.BigEndian.Uint64(v[i : i+8]) if _, ok := sc.senderInfo[senderID]; ok { @@ -976,9 +976,6 @@ func (p *TxPool) OnNewBlock(stateChanges map[string]senderInfo, unwindTxs, mined return err } defer tx.Rollback() - - p.lock.Lock() - defer p.lock.Unlock() protocolBaseFee, pendingBaseFee = p.setBaseFee(protocolBaseFee, pendingBaseFee) if err := senders.onNewBlock(tx, stateChanges, unwindTxs, minedTxs, blockHeight, blockHash); err != nil { return err @@ -991,6 +988,8 @@ func (p *TxPool) OnNewBlock(stateChanges map[string]senderInfo, unwindTxs, mined return err } + p.lock.Lock() + defer p.lock.Unlock() if err := onNewBlock(tx, senders, unwindTxs, minedTxs.txs, protocolBaseFee, pendingBaseFee, p.pending, p.baseFee, p.queued, p.txNonce2Tx, p.byHash, p.discardLocked); err != nil { return err }