Skip to content

Commit

Permalink
fixed nil pointer exceptions when using the explorer pre-genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 14, 2023
1 parent 4e97267 commit 0d67f4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func buildEpochPageData(epoch uint64) (*models.EpochPageData, time.Duration) {
NextEpoch: nextEpoch,
Ts: utils.EpochToTime(epoch),
Synchronized: syncedEpochs[epoch],
Finalized: uint64(finalizedHead.Data.Header.Message.Slot) >= lastSlot,
}

if finalizedHead != nil {
pageData.Finalized = uint64(finalizedHead.Data.Header.Message.Slot) >= lastSlot
}

dbEpochs := services.GlobalBeaconService.GetDbEpochs(epoch, 1)
Expand Down
17 changes: 10 additions & 7 deletions handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,16 @@ func buildSlotPageData(blockSlot int64, blockRoot []byte) (*models.SlotPageData,
logrus.Printf("slot page called: %v", slot)

pageData := &models.SlotPageData{
Slot: slot,
Epoch: utils.EpochOfSlot(slot),
EpochFinalized: uint64(finalizedHead.Data.Header.Message.Slot) >= slot,
Ts: utils.SlotToTime(slot),
NextSlot: slot + 1,
PreviousSlot: slot - 1,
Future: slot >= currentSlot,
Slot: slot,
Epoch: utils.EpochOfSlot(slot),
Ts: utils.SlotToTime(slot),
NextSlot: slot + 1,
PreviousSlot: slot - 1,
Future: slot >= currentSlot,
}

if finalizedHead != nil {
pageData.EpochFinalized = uint64(finalizedHead.Data.Header.Message.Slot) >= slot
}

assignments, err := services.GlobalBeaconService.GetEpochAssignments(utils.EpochOfSlot(slot))
Expand Down

0 comments on commit 0d67f4c

Please sign in to comment.