diff --git a/handlers/slot.go b/handlers/slot.go index 850221e8..74771d8a 100644 --- a/handlers/slot.go +++ b/handlers/slot.go @@ -151,16 +151,21 @@ func buildSlotPageData(blockSlot int64, blockRoot []byte) (*models.SlotPageData, blockData, err = services.GlobalBeaconService.GetSlotDetailsByBlockroot(blockRoot, false) } - if blockData == nil && err == nil { - // check for orphaned block - if blockSlot > -1 { - dbBlocks := services.GlobalBeaconService.GetDbBlocksForSlots(uint64(blockSlot), 0, true) - if len(dbBlocks) > 0 { - blockRoot = dbBlocks[0].Root + if err == nil { + if blockData == nil { + // check for orphaned block + if blockSlot > -1 { + dbBlocks := services.GlobalBeaconService.GetDbBlocksForSlots(uint64(blockSlot), 0, true) + if len(dbBlocks) > 0 { + blockRoot = dbBlocks[0].Root + } } - } - if blockRoot != nil { - blockData = services.GlobalBeaconService.GetOrphanedBlock(blockRoot) + if blockRoot != nil { + blockData = services.GlobalBeaconService.GetOrphanedBlock(blockRoot) + } + } else { + // check orphaned status + blockData.Orphaned = services.GlobalBeaconService.CheckBlockOrphanedStatus(blockData.Root) } } diff --git a/services/beaconservice.go b/services/beaconservice.go index a69c36a7..6ab89685 100644 --- a/services/beaconservice.go +++ b/services/beaconservice.go @@ -713,6 +713,18 @@ func (bs *BeaconService) GetDbBlocksByParentRoot(parentRoot []byte) []*dbtypes.B return resBlocks } +func (bs *BeaconService) CheckBlockOrphanedStatus(blockRoot []byte) bool { + cachedBlock := bs.indexer.GetCachedBlock(blockRoot) + if cachedBlock != nil { + return !cachedBlock.IsCanonical(bs.indexer, nil) + } + dbRefs := db.GetBlockOrphanedRefs([][]byte{blockRoot}) + if len(dbRefs) > 0 { + return true + } + return false +} + func (bs *BeaconService) GetValidatorActivity() (map[uint64]uint8, uint64) { activityMap := map[uint64]uint8{} epochLimit := uint64(3) diff --git a/templates/index/recentSlots.html b/templates/index/recentSlots.html index 3511da2e..06b71575 100644 --- a/templates/index/recentSlots.html +++ b/templates/index/recentSlots.html @@ -52,7 +52,7 @@
Proposed {{ else if eq .Status 2 }} - Missed (Orphaned) + Orphaned {{ else }} Unknown {{ end }}