mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-15 23:38: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
|
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))
|
stateChanges := etl.NewCollector(a.logPrefix, "", etl.NewOldestEntryBuffer(etl.BufferOptimalSize))
|
||||||
defer stateChanges.Close()
|
defer stateChanges.Close()
|
||||||
|
|
||||||
@ -311,21 +326,6 @@ func (a *Aggregator22) Unwind(ctx context.Context, txUnwindTo uint64, stateLoad
|
|||||||
return err
|
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 {
|
if err := a.logAddrs.prune(txUnwindTo, math2.MaxUint64); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -524,14 +524,22 @@ func (h *History) pruneF(step uint64, txFrom, txTo uint64, f func(txNum uint64,
|
|||||||
if txNum >= txTo {
|
if txNum >= txTo {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
_, vv, _ := valsC.SeekExact(v[len(v)-8:])
|
key, txnNumBytes := v[:len(v)-8], v[len(v)-8:]
|
||||||
if err := f(txNum, v[:len(v)-8], vv); err != nil {
|
{
|
||||||
return err
|
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 {
|
if err = idxC.DeleteExact(key, k); err != nil {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = idxC.DeleteExact(v[:len(v)-8], k); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// This DeleteCurrent needs to the the last in the loop iteration, because it invalidates k and v
|
// 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