cardano-docker/scripts/functions/current_epoch
2021-02-13 10:19:38 -05:00

10 lines
445 B
Bash

#!/bin/bash
GENESIS=${NODE_PATH}/shelley-genesis.json
startTimeGenesis=$(cat ${GENESIS} | jq -r .systemStart)
startTimeSec=$(date --date=${startTimeGenesis} +%s) #in seconds (UTC)
currentTimeSec=$(date -u +%s) #in seconds (UTC)
epochLength=$(cat ${GENESIS} | jq -r .epochLength)
currentEPOCH=$(( (${currentTimeSec}-${startTimeSec}) / ${epochLength} )) #returns a integer number, we like that
echo ${currentEPOCH}