Skip to content

Commit

Permalink
fix(notifications): properly initialize efficiency map in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbitfly committed Oct 31, 2024
1 parent 3adaf9d commit 6f52db8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func collectNotifications(startEpoch uint64) error {
if err != nil {
return err
}
defer tx.Rollback()
defer utils.Rollback(tx)

err = notification.QueueWebhookNotifications(notifications, tx)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions backend/pkg/notification/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,13 @@ func collectGroupEfficiencyNotifications(notificationsByUserID types.Notificatio
return fmt.Errorf("error getting proposal assignments: %w", err)
}
for _, assignment := range proposalAssignments.Data {
if _, ok := efficiencyMap[types.ValidatorIndex(assignment.ValidatorIndex)]; !ok {
efficiencyMap[types.ValidatorIndex(assignment.ValidatorIndex)] = &dbResult{
ValidatorIndex: assignment.ValidatorIndex,
AttestationReward: decimal.Decimal{},
AttestationIdealReward: decimal.Decimal{},
}
}
efficiencyMap[types.ValidatorIndex(assignment.ValidatorIndex)].BlocksScheduled++
}

Expand All @@ -538,6 +545,13 @@ func collectGroupEfficiencyNotifications(notificationsByUserID types.Notificatio
efficiencyMap[types.ValidatorIndex(s.Data.Message.ProposerIndex)].BlocksProposed++

for i, validatorIndex := range syncAssignments.Data.Validators {
if _, ok := efficiencyMap[types.ValidatorIndex(validatorIndex)]; !ok {
efficiencyMap[types.ValidatorIndex(validatorIndex)] = &dbResult{
ValidatorIndex: uint64(validatorIndex),
AttestationReward: decimal.Decimal{},
AttestationIdealReward: decimal.Decimal{},
}
}
efficiencyMap[types.ValidatorIndex(validatorIndex)].SyncScheduled++

if utils.BitAtVector(s.Data.Message.Body.SyncAggregate.SyncCommitteeBits, i) {
Expand Down

0 comments on commit 6f52db8

Please sign in to comment.