From 70d371454951efac998908228ad3365a4722be3d Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Sat, 28 Aug 2021 11:06:21 +0700 Subject: [PATCH] add state check assert routine --- txpool/pool.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/txpool/pool.go b/txpool/pool.go index 6f7678298..06513e53c 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -542,6 +542,26 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce, sendersWithoutTransa return evicted, err } } + if ASSERT { + _ = tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error { + vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8]) + if err != nil { + return err + } + if len(vv) == 0 { + cc, _ := tx.Cursor(kv.PooledSenderIDToAdress) + last, lastAddr, _ := cc.Last() + if len(last) > 0 { + fmt.Printf("last: %d,%x\n", binary.BigEndian.Uint64(last), lastAddr) + } + fmt.Printf("now: %d\n", sc.senderID) + fmt.Printf("not foundd: %d,%x,%x,%x\n", binary.BigEndian.Uint64(v[:8]), k, v, vv) + fmt.Printf("aa: %x,%x,%x\n", k, v, vv) + panic("no-no") + } + return nil + }) + } c, err := tx.RwCursor(kv.PoolStateEviction) if err != nil {