From 52d9ed8500b365f8218f7d5056a7304aeb18ad7c Mon Sep 17 00:00:00 2001 From: Sergey Kisel Date: Tue, 9 Jun 2026 13:08:20 +0200 Subject: [PATCH] fix: add epoch_no DESC sort to getLatestEpochInfo and getLatestEpochParameters Without explicit ordering, the Koios API may return a stale node's entry at position [0], causing these methods to return outdated epoch data. Fixes #190 Co-Authored-By: Claude Sonnet 4.6 --- .../client/backend/api/epoch/impl/EpochServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java b/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java index 8448966..f800440 100644 --- a/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java @@ -10,6 +10,8 @@ import rest.koios.client.backend.api.epoch.model.EpochParams; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.backend.factory.options.Order; +import rest.koios.client.backend.factory.options.SortType; import retrofit2.Call; import java.util.Collections; @@ -35,7 +37,7 @@ public EpochServiceImpl(String baseUrl, String apiToken) { @Override public Result getLatestEpochInfo() throws ApiException { - Options options = Options.builder().option(Limit.of(1)).build(); + Options options = Options.builder().option(Limit.of(1)).option(Order.by("epoch_no", SortType.DESC)).build(); Call> call = epochApi.getEpochInformation(null, false, optionsToParamMap(options)); return processResponseGetOne(call); } @@ -55,7 +57,7 @@ public Result> getEpochInformation(boolean includeNextEpoch, Opt @Override public Result getLatestEpochParameters() throws ApiException { - Options options = Options.builder().option(Limit.of(1)).build(); + Options options = Options.builder().option(Limit.of(1)).option(Order.by("epoch_no", SortType.DESC)).build(); Call> call = epochApi.getEpochParameters(optionsToParamMap(options)); return processResponseGetOne(call); }