add state check assert routine

This commit is contained in:
alex.sharov 2021-08-27 16:39:46 +07:00
parent 7ed9ddbf38
commit 937a19167b

View File

@ -1120,6 +1120,9 @@ func (p *TxPool) discardLocked(mt *metaTx) {
func (p *TxPool) fromDB(ctx context.Context, tx kv.RwTx, coreTx kv.Tx) error { func (p *TxPool) fromDB(ctx context.Context, tx kv.RwTx, coreTx kv.Tx) error {
p.lock.Lock() p.lock.Lock()
defer p.lock.Unlock() defer p.lock.Unlock()
if err := p.senders.fromDB(ctx, tx, coreTx); err != nil {
return err
}
if ASSERT { if ASSERT {
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error { tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8]) vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8])
@ -1133,15 +1136,13 @@ func (p *TxPool) fromDB(ctx context.Context, tx kv.RwTx, coreTx kv.Tx) error {
} }
return nil return nil
}) })
fmt.Printf("not foundd: %x,%x,%x\n", k, v, vv) fmt.Printf("now: %d\n", p.senders.senderID)
fmt.Printf("not foundd: %d,%x,%x,%x\n", binary.BigEndian.Uint64(v[:8]), k, v, vv)
panic("no-no") panic("no-no")
} }
return nil return nil
}) })
} }
if err := p.senders.fromDB(ctx, tx, coreTx); err != nil {
return err
}
if err := tx.ForEach(kv.RecentLocalTransaction, nil, func(k, v []byte) error { if err := tx.ForEach(kv.RecentLocalTransaction, nil, func(k, v []byte) error {
hashID := [32]byte{} hashID := [32]byte{}