add state check assert routine

This commit is contained in:
alex.sharov 2021-08-27 14:42:47 +07:00
parent afdb0c7598
commit 8673a30ea6

View File

@ -572,13 +572,15 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
if byNonce.count(binary.BigEndian.Uint64(id)) > 0 { if byNonce.count(binary.BigEndian.Uint64(id)) > 0 {
return nil return nil
} }
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error { if ASSERT {
senderID := binary.BigEndian.Uint64(v[:8]) tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
if senderID == binary.BigEndian.Uint64(id) { senderID := binary.BigEndian.Uint64(v[:8])
panic("why?") if senderID == binary.BigEndian.Uint64(id) {
} panic("why?")
return nil }
}) return nil
})
}
if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil { if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil {
return err return err
} }
@ -589,17 +591,19 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
return err return err
} }
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error { if ASSERT {
vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8]) tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
if err != nil { vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8])
return err if err != nil {
} return err
if len(vv) == 0 { }
fmt.Printf("no: %x,%x\n", id, addr) if len(vv) == 0 {
panic("no-no") fmt.Printf("no: %x,%x\n", id, addr)
} panic("no-no")
return nil }
}) return nil
})
}
i++ i++
return nil return nil
}); err != nil { }); err != nil {