mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-15 15:28:19 +00:00
erigon22: prune - check key existance (#588)
This commit is contained in:
parent
4945162dd7
commit
59dfcc471c
@ -287,6 +287,21 @@ func (a *Aggregator22) Unwind(ctx context.Context, txUnwindTo uint64, stateLoad
|
||||
return nil
|
||||
}
|
||||
|
||||
codeChanges := etl.NewCollector(a.logPrefix, "", etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
|
||||
defer codeChanges.Close()
|
||||
|
||||
if err := a.code.pruneF(step, txUnwindTo, math2.MaxUint64, func(txNum uint64, k, v []byte) error {
|
||||
if err := codeChanges.Collect(k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := codeChanges.Load(a.rwTx, kv.PlainContractCode, etl.IdentityLoadFunc, etl.TransformArgs{Quit: ctx.Done()}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stateChanges := etl.NewCollector(a.logPrefix, "", etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
|
||||
defer stateChanges.Close()
|
||||
|
||||
@ -311,21 +326,6 @@ func (a *Aggregator22) Unwind(ctx context.Context, txUnwindTo uint64, stateLoad
|
||||
return err
|
||||
}
|
||||
|
||||
codeChanges := etl.NewCollector(a.logPrefix, "", etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
|
||||
defer codeChanges.Close()
|
||||
|
||||
if err := a.code.pruneF(step, txUnwindTo, math2.MaxUint64, func(txNum uint64, k, v []byte) error {
|
||||
if err := codeChanges.Collect(k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := codeChanges.Load(a.rwTx, kv.PlainContractCode, etl.IdentityLoadFunc, etl.TransformArgs{Quit: ctx.Done()}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.logAddrs.prune(txUnwindTo, math2.MaxUint64); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -524,14 +524,22 @@ func (h *History) pruneF(step uint64, txFrom, txTo uint64, f func(txNum uint64,
|
||||
if txNum >= txTo {
|
||||
break
|
||||
}
|
||||
_, vv, _ := valsC.SeekExact(v[len(v)-8:])
|
||||
if err := f(txNum, v[:len(v)-8], vv); err != nil {
|
||||
return err
|
||||
key, txnNumBytes := v[:len(v)-8], v[len(v)-8:]
|
||||
{
|
||||
kk, vv, err := valsC.SeekExact(txnNumBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f(txNum, key, vv); err != nil {
|
||||
return err
|
||||
}
|
||||
if kk != nil {
|
||||
if err = valsC.DeleteCurrent(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if err = valsC.DeleteCurrent(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = idxC.DeleteExact(v[:len(v)-8], k); err != nil {
|
||||
if err = idxC.DeleteExact(key, k); err != nil {
|
||||
return err
|
||||
}
|
||||
// This DeleteCurrent needs to the the last in the loop iteration, because it invalidates k and v
|
||||
|
Loading…
Reference in New Issue
Block a user