Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed function to next slot lead because of wrong implementation #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions config/.bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@ function stats() {
echo "$(jcli rest v0 node stats get -h http://127.0.0.1:${REST_PORT}/api)"
}

function current_blocktime() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_blocktime & next should be moved down to line 178, replacing the old version of "next".

chainstartdate=$(settings | grep "block0Time:" | awk '{print $2}' | tr -d '"' | xargs -I{} date "+%s" -d {})
nowtime=$(date +%s)

chaintime=$(($nowtime-$chainstartdate))

slot=$((($chaintime % 86400)))
epoch=$(($chaintime / 86400))
}

function next() {
NEWEPOCH=$(stats | grep Date | grep -Eo '[0-9]{1,3}' | awk 'NR==1{print $1}')
maxSlots=$(leaders | grep -P 'scheduled_at_date: "'$NEWEPOCH'.' | grep -P '[0-9]+' | wc -l)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/leaders/leader_logs ;)

leaderSlots=$(leaders | grep -P 'scheduled_at_date: "'$NEWEPOCH'.' | grep -P '[0-9]+' | awk -v i="$rowIndex" '{print $2}' | awk -F "." '{print $2}' | tr '"' ' ' | sort -V)
for (( rowIndex = 1; rowIndex <= $maxSlots ; rowIndex++ ))
do
current_blocktime
currentSlotTime=$((slot/2))
#currentSlotTime=$(stats | grep 'lastBlockDate: "'$NEWEPOCH'.' | awk -F "." '{print $2}' | tr '"' ' ')
blockCreatedSlotTime=$(awk -v i="$rowIndex" 'NR==i {print $1}' <<< $leaderSlots)

if [[ $blockCreatedSlotTime -ge $currentSlotTime ]];
then
timeToNextSlotLead=$(($blockCreatedSlotTime-$currentSlotTime))
currentTime=$(date +%s)
nextBlockDate=$(($chainstartdate+$blockCreatedSlotTime*2+($epoch)*86400))
echo "TimeToNextSlotLead: " $(awk '{print int($1/(3600))":"int(($1/60)%60)":"int($1%60)}' <<< $(($timeToNextSlotLead*2))) "("$(awk '{print strftime("%c",$1)}' <<< $nextBlockDate)") - $(($blockCreatedSlotTime))"
break;
fi
done
}

function bal() {
echo "$(jcli rest v0 account get $(cat ~/files/receiver_account.txt) -h http://127.0.0.1:${REST_PORT}/api)"
}
Expand Down