From 9dc4240ed4e385c49f1341b962764057f0331277 Mon Sep 17 00:00:00 2001 From: Ola Date: Tue, 15 Sep 2020 00:36:58 +0200 Subject: [PATCH] KES expiration calculation --- scripts/cnode-helper-scripts/cntools.library | 5 +++-- scripts/cnode-helper-scripts/cntools.sh | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/cnode-helper-scripts/cntools.library b/scripts/cnode-helper-scripts/cntools.library index 25c9f06c8..5fea55e6d 100644 --- a/scripts/cnode-helper-scripts/cntools.library +++ b/scripts/cnode-helper-scripts/cntools.library @@ -463,7 +463,8 @@ timeUntilNextEpoch() { # Description: Offline calculation of current KES period based on reference tip # Return : current KES period on STDOUT getCurrentKESperiod() { - current_kes_period=$(( $(getSlotTipRef) / slots_per_kes_period )) + tip_ref=$(getSlotTipRef) + current_kes_period=$(( tip_ref / slots_per_kes_period )) echo "${current_kes_period}" } @@ -481,7 +482,7 @@ kesExpiration() { current_kes_period=$(getCurrentKESperiod) remaining_kes_periods=$(( max_kes_evolutions - ( current_kes_period - pool_kes_start_period ) )) current_time_sec=$(date -u +%s) - expiration_time_sec=$(( current_time_sec - ( slot_length * slots_per_kes_period ) + ( slot_length * slots_per_kes_period * remaining_kes_periods ) )) + expiration_time_sec=$(( current_time_sec - ( slot_length * (tip_ref % slots_per_kes_period) ) + ( slot_length * slots_per_kes_period * remaining_kes_periods ) )) expiration_time_sec_diff=$(( expiration_time_sec - current_time_sec )) expiration_date=$(date --date=@${expiration_time_sec}) } diff --git a/scripts/cnode-helper-scripts/cntools.sh b/scripts/cnode-helper-scripts/cntools.sh index d401b2866..0ee18b81d 100755 --- a/scripts/cnode-helper-scripts/cntools.sh +++ b/scripts/cnode-helper-scripts/cntools.sh @@ -251,11 +251,11 @@ else tip_diff=$(getSlotTipDiff) slot_interval=$(slotInterval) if [[ ${tip_diff} -le $(( slot_interval * 2 )) ]]; then - say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${GREEN}-${tip_diff} :)${NC}")" + say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${GREEN}${tip_diff} :)${NC}")" elif [[ ${tip_diff} -le $(( slot_interval * 3 )) ]]; then - say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${ORANGE}-${tip_diff} :|${NC}")" + say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${ORANGE}${tip_diff} :|${NC}")" else - say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${RED}-${tip_diff} :(${NC}")" + say "$(printf " %-20s %73s" "What would you like to do?" "Node Sync: ${RED}${tip_diff} :(${NC}")" fi fi echo