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,6 +572,7 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
if byNonce.count(binary.BigEndian.Uint64(id)) > 0 {
return nil
}
if ASSERT {
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
senderID := binary.BigEndian.Uint64(v[:8])
if senderID == binary.BigEndian.Uint64(id) {
@ -579,6 +580,7 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
}
return nil
})
}
if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil {
return err
}
@ -589,6 +591,7 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
return err
}
if ASSERT {
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
vv, err := tx.GetOne(kv.PooledSenderIDToAdress, v[:8])
if err != nil {
@ -600,6 +603,7 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
}
return nil
})
}
i++
return nil
}); err != nil {