From d9f67eccb8501cbb7a93893954f20c2f9801b67f Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 3 Aug 2023 21:40:09 +0200 Subject: [PATCH] small fixes --- handlers/slot.go | 8 ++++++-- services/beaconservice.go | 6 ++++-- test-config.yaml | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/handlers/slot.go b/handlers/slot.go index db333fcf..dc6824cd 100644 --- a/handlers/slot.go +++ b/handlers/slot.go @@ -164,10 +164,14 @@ func buildSlotPageData(blockSlot int64, blockRoot []byte) (*models.SlotPageData, } } - if blockData == nil { + var slot uint64 + if blockData != nil { + slot = uint64(blockData.Header.Data.Header.Message.Slot) + } else if blockSlot > -1 { + slot = uint64(blockSlot) + } else { return nil, -1 } - slot := uint64(blockData.Header.Data.Header.Message.Slot) logrus.Printf("slot page called: %v", slot) pageData := &models.SlotPageData{ diff --git a/services/beaconservice.go b/services/beaconservice.go index 1af173a7..4cec0faa 100644 --- a/services/beaconservice.go +++ b/services/beaconservice.go @@ -288,11 +288,11 @@ func (bs *BeaconService) GetDbEpochs(firstEpoch uint64, limit uint32) []*dbtypes idxHeadEpoch = utils.EpochOfSlot(bs.indexer.GetHeadSlot()) } - lastEpoch := firstEpoch - uint64(limit) + lastEpoch := int64(firstEpoch) - int64(limit) if lastEpoch < 0 { lastEpoch = 0 } - for epochIdx := int64(firstEpoch); epochIdx >= int64(lastEpoch) && resIdx < int(limit); epochIdx-- { + for epochIdx := int64(firstEpoch); epochIdx >= lastEpoch && resIdx < int(limit); epochIdx-- { epoch := uint64(epochIdx) var resEpoch *dbtypes.Epoch if dbIdx < dbCnt && dbEpochs[dbIdx].Epoch == epoch { @@ -340,6 +340,7 @@ func (bs *BeaconService) GetDbBlocks(firstSlot uint64, limit int32, withOrphaned } } } + slot-- } if resIdx < int(limit) { @@ -388,6 +389,7 @@ func (bs *BeaconService) GetDbBlocksForSlots(firstSlot uint64, slotLimit uint32, } } } + slot-- } if slot > lastSlot { diff --git a/test-config.yaml b/test-config.yaml index 2764368f..242561a4 100644 --- a/test-config.yaml +++ b/test-config.yaml @@ -1,8 +1,8 @@ # Chain network configuration chain: #name: "mainnet" - genesisTimestamp: 1690484700 - genesisValidatorsRoot: "0xbf3c3d4683a5a4d286cd2a5ef7a5c1702f649eee82cdc7e87e05030102d12ccf" + #genesisTimestamp: 1690484700 + #genesisValidatorsRoot: "0xbf3c3d4683a5a4d286cd2a5ef7a5c1702f649eee82cdc7e87e05030102d12ccf" configPath: "config.yaml" #genesisTimestamp: 1688126460 #configPath: "config-devnet7.yaml"