mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +00:00
Senders prune logging (#2645)
This commit is contained in:
parent
0d79c19f21
commit
fd69b509a5
@ -347,8 +347,12 @@ func UnwindSendersStage(s *UnwindState, tx kv.RwTx, cfg SendersCfg, ctx context.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PruneSendersStage(s *PruneState, tx kv.RwTx, cfg SendersCfg, ctx context.Context) (err error) {
|
func PruneSendersStage(s *PruneState, tx kv.RwTx, cfg SendersCfg, ctx context.Context) (err error) {
|
||||||
|
if !cfg.prune.TxIndex.Enabled() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
logEvery := time.NewTicker(logInterval)
|
||||||
|
defer logEvery.Stop()
|
||||||
to := cfg.prune.TxIndex.PruneTo(s.ForwardProgress)
|
to := cfg.prune.TxIndex.PruneTo(s.ForwardProgress)
|
||||||
|
|
||||||
useExternalTx := tx != nil
|
useExternalTx := tx != nil
|
||||||
if !useExternalTx {
|
if !useExternalTx {
|
||||||
tx, err = cfg.db.BeginRw(ctx)
|
tx, err = cfg.db.BeginRw(ctx)
|
||||||
@ -357,24 +361,32 @@ func PruneSendersStage(s *PruneState, tx kv.RwTx, cfg SendersCfg, ctx context.Co
|
|||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
}
|
}
|
||||||
if cfg.prune.TxIndex.Enabled() {
|
|
||||||
c, err := tx.RwCursor(kv.Senders)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to create cursor for pruning %w", err)
|
|
||||||
}
|
|
||||||
defer c.Close()
|
|
||||||
|
|
||||||
for k, _, err := c.First(); k != nil; k, _, err = c.Next() {
|
c, err := tx.RwCursor(kv.Senders)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to create cursor for pruning %w", err)
|
||||||
}
|
}
|
||||||
blockNum := binary.BigEndian.Uint64(k)
|
defer c.Close()
|
||||||
if blockNum >= to {
|
|
||||||
break
|
for k, _, err := c.First(); k != nil; k, _, err = c.Next() {
|
||||||
}
|
if err != nil {
|
||||||
if err = c.DeleteCurrent(); err != nil {
|
return err
|
||||||
return fmt.Errorf("failed to remove for block %d: %w", blockNum, err)
|
}
|
||||||
}
|
blockNum := binary.BigEndian.Uint64(k)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-logEvery.C:
|
||||||
|
log.Info(fmt.Sprintf("[%s]", s.LogPrefix()), "table", kv.Senders, "block", blockNum)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return common.ErrStopped
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if blockNum >= to {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err = c.DeleteCurrent(); err != nil {
|
||||||
|
return fmt.Errorf("failed to remove for block %d: %w", blockNum, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !useExternalTx {
|
if !useExternalTx {
|
||||||
|
Loading…
Reference in New Issue
Block a user