From d0c0bd9a252f68c14451bcc40acdfc8401e43d0a Mon Sep 17 00:00:00 2001 From: sqrrm Date: Sat, 20 Apr 2019 15:18:23 +0200 Subject: [PATCH] Count cycles correctly, fix #2706 --- .../java/bisq/core/dao/governance/period/CycleService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/dao/governance/period/CycleService.java b/core/src/main/java/bisq/core/dao/governance/period/CycleService.java index 9630f68884f..acc4cfa0313 100644 --- a/core/src/main/java/bisq/core/dao/governance/period/CycleService.java +++ b/core/src/main/java/bisq/core/dao/governance/period/CycleService.java @@ -90,7 +90,8 @@ public void addFirstCycle() { } public int getCycleIndex(Cycle cycle) { - return (cycle.getHeightOfFirstBlock() - genesisBlockHeight) / cycle.getDuration(); + Optional previousCycle = getCycle(cycle.getHeightOfFirstBlock() - 1, daoStateService.getCycles()); + return previousCycle.map(cycle1 -> getCycleIndex(cycle1) + 1).orElse(0); } public boolean isTxInCycle(Cycle cycle, String txId) {