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 {
return nil
}
tx.ForEach(kv.PooledTransaction, nil, func(k, v []byte) error {
senderID := binary.BigEndian.Uint64(v[:8])
if senderID == binary.BigEndian.Uint64(id) {
panic("why?")
}
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) {
panic("why?")
}
return nil
})
}
if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil {
return err
}
@ -589,17 +591,19 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
return err
}
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 {
fmt.Printf("no: %x,%x\n", id, addr)
panic("no-no")
}
return nil
})
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 {
fmt.Printf("no: %x,%x\n", id, addr)
panic("no-no")
}
return nil
})
}
i++
return nil
}); err != nil {