Skip to content

Commit

Permalink
KES expiration calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitz0 committed Sep 14, 2020
1 parent 2406aef commit 9dc4240
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions scripts/cnode-helper-scripts/cntools.library
Expand Up @@ -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}"
}

Expand All @@ -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})
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/cnode-helper-scripts/cntools.sh
Expand Up @@ -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
Expand Down

0 comments on commit 9dc4240

Please sign in to comment.