key_block_time_by_height
1 #!/bin/sh 2 3 ## Script printing human-readable time reported by miner in key block at specified height. 4 5 function human_time_s() { 6 erl -milliseconds "${1:?}" -noinput -eval ' 7 {ok, [[MsS]]} = init:get_argument(milliseconds), 8 Ms = list_to_integer(MsS), 9 HumanReadableString = calendar:system_time_to_rfc3339(Ms, [{offset, "Z"}, {unit, millisecond}]), %% OTP >= 21.0 10 io:fwrite("~s~n", [HumanReadableString]), 11 init:stop().' 12 } 13 14 ApiAddress="${1:?}" 15 ExtApiPort=3013 16 KeyBlockHeight="${2:?}" 17 18 human_time_s "$(curl -sS http://${ApiAddress:?}:${ExtApiPort:?}/v3/key-blocks/height/${KeyBlockHeight:?} | jq .time)"