Skip to content

Commit

Permalink
Fix: improved API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Czeladka committed Nov 24, 2023
1 parent dd1c61d commit ab22a0c
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@ long epochToAbsoluteSlot(int epochNo) {
return firstShelleySlot + absoluteSlotAssumingEra(Shelley, postByronEpochs);
}

/**
* Converts epoch number to the UTC Time at the beginning of given epoch
*
* @param epochNo epoch number
* @return UTC time
*/
public LocalDateTime beginningOfEpochToUTCTime(int epochNo) {
return epochToUTCTime(epochNo, START);
}

/**
* Converts epoch number to the UTC Time at the end of a given epoch
*
* @param epochNo epoch number
* @return UTC time
*/
public LocalDateTime endingOfEpochToUTCTime(int epochNo) {
return epochToUTCTime(epochNo, END);
}

/**
* Converts epoch number to UTC time.
*
Expand Down Expand Up @@ -108,19 +128,14 @@ long absoluteSlotAssumingEra(Era era, int epochNo, EpochOffset epochOffset) {
};
}

/**
* @param era
* @param epochNo
* @return
*/
long absoluteSlotAssumingEra(Era era, int epochNo) {
long allSlotsPerEra = genesisConfig.slotsPerEpoch(era) * epochNo;

return allSlotsPerEra + ((genesisConfig.slotsPerEpoch(era)) - 1);
}

/**
* Returns first slot of a given epoch.
* Returns first slot of a given epoch based on era.
*
* @param era - cardano era e.g. Byron, Shelley
* @param epochNo - epoch number, e.g. 208
Expand All @@ -131,7 +146,7 @@ long firstEpochSlot(Era era, int epochNo) {
}

/**
* Returns last slot of a given epoch.
* Returns last slot of a given epoch based on era.
*
* @param era - cardano era e.g. Byron, Shelley
* @param epochNo - epoch number, e.g. 208
Expand Down

0 comments on commit ab22a0c

Please sign in to comment.