Skip to content

Commit

Permalink
1. Rationalising node address derivation.
Browse files Browse the repository at this point in the history
  • Loading branch information
asladeofgreen committed Nov 27, 2024
1 parent 5381d57 commit 0d75104
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 34 deletions.
4 changes: 2 additions & 2 deletions cmds/chain/query/view_account.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ function _help() {
function _main()
{
local ACCOUNT_ID=${1}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl)

curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "1")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw "$(_get_json_rpc_request_data "$ACCOUNT_ID")" \
| jq
}
Expand All @@ -43,7 +44,6 @@ function _get_json_rpc_request_data()
}'
}


# ----------------------------------------------------------------
# ENTRY POINT
# ----------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions cmds/chain/query/view_auction_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ function _help() {

function _main()
{
local NODE_ID=${1}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")

curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl)" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -31,19 +34,21 @@ function _main()
source "$CCTL"/utils/main.sh

unset _HELP
unset _NODE_ID

for ARGUMENT in "$@"
do
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
case "$KEY" in
help) _HELP="show" ;;
node) _NODE_ID=${VALUE} ;;
*)
esac
done

if [ "${_HELP:-""}" = "show" ]; then
_help
else
_main
_main "${_NODE_ID:-"1"}"
fi
20 changes: 12 additions & 8 deletions cmds/chain/query/view_block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ function _help() {

function _main()
{
local BLOCK_ID=${1}
local NODE_ID=${1}
local BLOCK_ID=${2}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")
local is_block_height

if [ "$BLOCK_ID" ]; then
if [ $(get_is_numeric "$BLOCK_ID") = true ]; then
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -37,11 +39,11 @@ function _main()
}
}
}' \
| jq '.result.block_with_signatures'
| jq '.result'
else
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -52,18 +54,18 @@ function _main()
}
}
}' \
| jq '.result.block_with_signatures'
| jq '.result'
fi
else
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
"method": "chain_get_block"
}' \
| jq '.result.block_with_signatures'
| jq '.result'
fi
}

Expand All @@ -75,6 +77,7 @@ source "$CCTL"/utils/main.sh

unset _BLOCK_ID
unset _HELP
unset _NODE_ID

for ARGUMENT in "$@"
do
Expand All @@ -83,12 +86,13 @@ do
case "$KEY" in
block) _BLOCK_ID=${VALUE} ;;
help) _HELP="show" ;;
node) _NODE_ID=${VALUE} ;;
*)
esac
done

if [ "${_HELP:-""}" = "show" ]; then
_help
else
_main $_BLOCK_ID
_main "${_NODE_ID:-"1"}" "${_BLOCK_ID:-""}"
fi
14 changes: 9 additions & 5 deletions cmds/chain/query/view_block_transfers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ function _help() {

function _main()
{
local BLOCK_ID=${1}
local NODE_ID=${1}
local BLOCK_ID=${2}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")

if [ "$BLOCK_ID" ]; then
if [ $(get_is_numeric "$BLOCK_ID") = true ]; then
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl)" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -38,7 +40,7 @@ function _main()
else
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl)" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -53,7 +55,7 @@ function _main()
else
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl)" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -70,6 +72,7 @@ source "$CCTL"/utils/main.sh

unset _BLOCK_ID
unset _HELP
unset _NODE_ID

for ARGUMENT in "$@"
do
Expand All @@ -78,12 +81,13 @@ do
case "$KEY" in
block) _BLOCK_ID=${VALUE} ;;
help) _HELP="show" ;;
node) _NODE_ID=${VALUE} ;;
*)
esac
done

if [ "${_HELP:-""}" = "show" ]; then
_help
else
_main $_BLOCK_ID
_main "${_NODE_ID:-"1"}" "${_BLOCK_ID:-""}"
fi
5 changes: 3 additions & 2 deletions cmds/chain/query/view_era_summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ function _main()
{
local NODE_ID=${1}
local BLOCK_ID=${2}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")

if [ "$BLOCK_ID" ]; then
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -44,7 +45,7 @@ function _main()
else
curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand Down
2 changes: 1 addition & 1 deletion cmds/chain/query/view_tip_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function _render()
local NODE_ID=${1}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")
local NODE_API_RESPONSE

curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$NODE_ADDRESS_CURL" \
Expand Down
3 changes: 2 additions & 1 deletion cmds/chain/query/view_tx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ function _help() {
function _main()
{
local TX_ID=${1}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl)

curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand Down
16 changes: 3 additions & 13 deletions cmds/chain/query/view_validator_changes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,16 @@ function _help() {
DESCRIPTION
----------------------------------------------------------------
Displays validator change set.
ARGS
----------------------------------------------------------------
node Identifier of a node. Optional.
DEFAULTS
----------------------------------------------------------------
node 1
"
}

function _main()
{
local NODE_ID=${1}
local NODE_ADDRESS_CURL=$(get_address_of_sidecar_main_server_for_curl)

curl $CCTL_CURL_ARGS_FOR_NODE_RELATED_QUERIES \
--header 'Content-Type: application/json' \
--request POST "$(get_address_of_sidecar_main_server_for_curl "$NODE_ID")" \
--request POST "$NODE_ADDRESS_CURL" \
--data-raw '{
"id": 1,
"jsonrpc": "2.0",
Expand All @@ -42,21 +34,19 @@ function _main()
source "$CCTL"/utils/main.sh

unset _HELP
unset _NODE_ID

for ARGUMENT in "$@"
do
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
case "$KEY" in
help) _HELP="show" ;;
node) _NODE_ID=${VALUE} ;;
*)
esac
done

if [ "${_HELP:-""}" = "show" ]; then
_help
else
_main "${_NODE_ID:-"1"}"
_main
fi

0 comments on commit 0d75104

Please sign in to comment.