Skip to content

Commit

Permalink
Merge pull request #2644 from gobitfly/BIDS-2606/fix_validator_queue_…
Browse files Browse the repository at this point in the history
…update

(BIDS-2606) fix validator queue update
  • Loading branch information
recy21 authored Oct 25, 2023
2 parents 3de54b2 + 8076f10 commit dad8189
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ func SetBlockStatus(blocks []*types.CanonBlock) error {
}

// SaveValidatorQueue will save the validator queue into the database
func SaveValidatorQueue(validators *types.ValidatorQueue) error {
_, err := WriterDb.Exec(`
func SaveValidatorQueue(validators *types.ValidatorQueue, tx *sqlx.Tx) error {
_, err := tx.Exec(`
INSERT INTO queue (ts, entering_validators_count, exiting_validators_count)
VALUES (date_trunc('hour', now()), $1, $2)
ON CONFLICT (ts) DO UPDATE SET
Expand Down
12 changes: 12 additions & 0 deletions exporter/slot_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,19 @@ func RunSlotExporter(client rpc.Client, firstRun bool) error {
if err != nil {
return err
}

logger.Infof("exporting validation queue")
queue, err := client.GetValidatorQueue()
if err != nil {
return fmt.Errorf("error retrieving validator queue data: %w", err)
}

err = db.SaveValidatorQueue(queue, tx)
if err != nil {
return fmt.Errorf("error saving validator queue data: %w", err)
}
}

}
} else { // check if a late slot has been proposed in the meantime
if len(dbSlot.BlockRoot) < 32 && header != nil { // we have no slot in the db, but the node has a slot, export it
Expand Down

0 comments on commit dad8189

Please sign in to comment.