Skip to content

Commit

Permalink
select default node by default, and leave ping selection as an option
Browse files Browse the repository at this point in the history
  • Loading branch information
slowriot committed Oct 19, 2021
1 parent 92c1c8f commit 23e75ca
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
25 changes: 15 additions & 10 deletions close.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gaslimit="300000"

debug=${debug:-'false'}
dry_run=${dry_run:-'false'}
node_by_ping=${node_by_ping:-'false'}

version=$(akash version)
if [ "$?" != 0 ]; then
Expand Down Expand Up @@ -64,16 +65,20 @@ fi
echo "Chain ID: $chain_id"

node=$(head -1 <<< "$nodes")
lowest_ping=10000
for rpc in $nodes; do
hostname=$(cut -d '/' -f 3- <<< "$rpc" | cut -d ':' -f 1)
ping=$(ping -c1 "$hostname" | grep ^rtt | cut -d '/' -f 5)
if (( $(bc -l <<< "$ping < $lowest_ping") )); then
lowest_ping="$ping"
node="$rpc"
fi
done
echo "Selected node $node with lowest ping ${lowest_ping}ms"
if $node_by_ping; then
lowest_ping=10000
for rpc in $nodes; do
hostname=$(cut -d '/' -f 3- <<< "$rpc" | cut -d ':' -f 1)
ping=$(ping -c1 "$hostname" | grep ^rtt | cut -d '/' -f 5)
if (( $(bc -l <<< "$ping < $lowest_ping") )); then
lowest_ping="$ping"
node="$rpc"
fi
done
echo "Selected node $node with lowest ping ${lowest_ping}ms"
else
echo "Selected default node $node"
fi

function akash_tx {
# wrapper function to send a transaction
Expand Down
25 changes: 15 additions & 10 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ gaslimit="300000"

debug=${debug:-'false'}
dry_run=${dry_run:-'false'}
node_by_ping=${node_by_ping:-'false'}

if [ "$1" = "-y" ]; then
ask_to_confirm=false
Expand Down Expand Up @@ -79,16 +80,20 @@ fi
echo "Chain ID: $chain_id"

node=$(head -1 <<< "$nodes")
lowest_ping=10000
for rpc in $nodes; do
hostname=$(cut -d '/' -f 3- <<< "$rpc" | cut -d ':' -f 1)
ping=$(ping -c1 "$hostname" | grep ^rtt | cut -d '/' -f 5)
if (( $(bc -l <<< "$ping < $lowest_ping") )); then
lowest_ping="$ping"
node="$rpc"
fi
done
echo "Selected node $node with lowest ping ${lowest_ping}ms"
if $node_by_ping; then
lowest_ping=10000
for rpc in $nodes; do
hostname=$(cut -d '/' -f 3- <<< "$rpc" | cut -d ':' -f 1)
ping=$(ping -c1 "$hostname" | grep ^rtt | cut -d '/' -f 5)
if (( $(bc -l <<< "$ping < $lowest_ping") )); then
lowest_ping="$ping"
node="$rpc"
fi
done
echo "Selected node $node with lowest ping ${lowest_ping}ms"
else
echo "Selected default node $node"
fi

function akash_tx {
# wrapper function to send a transaction
Expand Down

0 comments on commit 23e75ca

Please sign in to comment.