Skip to content

Commit

Permalink
Count cycles correctly, fix bisq-network#2706
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrm committed Apr 20, 2019
1 parent f36823f commit d0c0bd9
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public void addFirstCycle() {
}

public int getCycleIndex(Cycle cycle) {
return (cycle.getHeightOfFirstBlock() - genesisBlockHeight) / cycle.getDuration();
Optional<Cycle> previousCycle = getCycle(cycle.getHeightOfFirstBlock() - 1, daoStateService.getCycles());
return previousCycle.map(cycle1 -> getCycleIndex(cycle1) + 1).orElse(0);
}

public boolean isTxInCycle(Cycle cycle, String txId) {
Expand Down

0 comments on commit d0c0bd9

Please sign in to comment.