Skip to content

Commit

Permalink
cleanup old entries from unfinalized_epochs table
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 24, 2025
1 parent fc1a58e commit 84df105
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions db/unfinalized_epochs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func GetUnfinalizedEpoch(epoch uint64, headRoot []byte) *dbtypes.UnfinalizedEpoc
return &unfinalizedEpoch
}

func DeleteUnfinalizedEpochsIn(epoch uint64, tx *sqlx.Tx) error {
_, err := tx.Exec(`DELETE FROM unfinalized_epochs WHERE epoch = $1`, epoch)
func DeleteUnfinalizedEpochsBefore(epoch uint64, tx *sqlx.Tx) error {
_, err := tx.Exec(`DELETE FROM unfinalized_epochs WHERE epoch < $1`, epoch)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions indexer/beacon/finalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ func (indexer *Indexer) finalizeEpoch(epoch phase0.Epoch, justifiedRoot phase0.R
}

// delete unfinalized epoch aggregations in epoch
if err := db.DeleteUnfinalizedEpochsIn(uint64(epoch), tx); err != nil {
return fmt.Errorf("failed deleting unfinalized epoch aggregations of epoch %v: %v", epoch, err)
if err := db.DeleteUnfinalizedEpochsBefore(uint64(epoch+1), tx); err != nil {
return fmt.Errorf("failed deleting unfinalized epoch aggregations <= epoch %v: %v", epoch, err)
}

// delete unfinalized forks for canonical roots
Expand Down

0 comments on commit 84df105

Please sign in to comment.