add condition to fix endIndex out of bounds

This commit is contained in:
wanwiset25 2025-06-11 18:37:02 +04:00
parent ae70b5dc14
commit 796ee818e3

View file

@ -467,6 +467,9 @@ func (api *API) getRewardFileNamesInRange(begin, end *rpc.BlockNumber) ([]reward
startIndex := sort.SearchInts(epochNumbers, int(beginHeader.Number.Int64()))
endIndex := sort.SearchInts(epochNumbers, int(endHeader.Number.Int64()))
if endIndex == len(epochNumbers) {
endIndex = endIndex - 1 //this is to prevent endIndex out of bounds when endInput is higher than last reward(epoch) block but lower than latest block
}
var rewardfileNamesInRange []rewardFileName
for i := startIndex; i <= endIndex; i++ {