From 7f1a72b9971d0da8e0138e7d2bcd01cfc80c3d08 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Fri, 27 Aug 2021 17:06:34 +0700 Subject: [PATCH] add state check assert routine --- txpool/pool.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/txpool/pool.go b/txpool/pool.go index 69b298c01..eafa76abb 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -1078,13 +1078,18 @@ func (p *TxPool) flush(tx kv.RwTx, senders *SendersCache) error { binary.BigEndian.PutUint64(v, metaTx.Tx.senderID) binary.BigEndian.PutUint64(v[8:], 0) // block num - timestamp copy(v[8+8:], metaTx.Tx.rlp) - currentV, err := tx.GetOne(kv.PooledTransaction, []byte(txHash)) - if err != nil { - return err - } - if currentV != nil && bytes.Equal(currentV, v) { - continue + if ASSERT { + if _, ok := p.senders.senderInfo[metaTx.Tx.senderID]; !ok { + info, err := p.senders.info(metaTx.Tx.senderID, tx) + if err != nil { + panic(err) + } + if info == nil { + panic("lost") + } + } } + if err := tx.Put(kv.PooledTransaction, []byte(txHash), v); err != nil { return err } @@ -1715,7 +1720,7 @@ func BroadcastLoop(ctx context.Context, db kv.RwDB, coreDB kv.RoDB, p *TxPool, s logEvery := time.NewTicker(timings.logEvery) defer logEvery.Stop() - commitEvery := time.NewTicker(3 * time.Second) + commitEvery := time.NewTicker(1 * time.Second) defer commitEvery.Stop() syncToNewPeersEvery := time.NewTicker(timings.syncToNewPeersEvery)