mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 11:32:20 +00:00
add state check assert routine
This commit is contained in:
parent
f160918baa
commit
87ef16fd5b
@ -558,6 +558,26 @@ var PoolProtocolBaseFeeKey = []byte("protocol_base_fee")
|
||||
func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
|
||||
sc.lock.Lock()
|
||||
defer sc.lock.Unlock()
|
||||
|
||||
//TODO: it's very naive eviction of all senders without transactions - and with O(n) complexity. We need more soft eviction policy.
|
||||
if err := tx.ForEach(kv.PooledSenderID, nil, func(addr, id []byte) error {
|
||||
if byNonce.count(binary.BigEndian.Uint64(id)) > 0 {
|
||||
return nil
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSenderIDToAdress, id, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSender, id, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
encID := make([]byte, 8)
|
||||
encIDs := make([]byte, 0, 1024)
|
||||
for addr, id := range sc.senderIDs {
|
||||
@ -579,25 +599,6 @@ func (sc *SendersCache) flush(tx kv.RwTx, byNonce *ByNonce) error {
|
||||
encIDs = append(encIDs, encID...)
|
||||
}
|
||||
|
||||
//TODO: it's very naive eviction of all senders without transactions - and with O(n) complexity. We need more soft eviction policy.
|
||||
if err := tx.ForEach(kv.PooledSenderID, nil, func(addr, id []byte) error {
|
||||
if byNonce.count(binary.BigEndian.Uint64(id)) > 0 {
|
||||
return nil
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSenderID, addr, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSenderIDToAdress, id, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Delete(kv.PooledSender, id, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sc.senderIDs = map[string]uint64{}
|
||||
|
||||
v := make([]byte, 8, 8+32)
|
||||
|
Loading…
Reference in New Issue
Block a user