Internally 192.168.42.9 is my BP.
Here is my topologyUpdater.sh for Node 1
#!/usr/bin/env bash
# shellcheck disable=SC2086,SC2034
# shellcheck source=/dev/null
PARENT="$(dirname $0)"
[[ -f "${PARENT}"/env ]] && . "${PARENT}"/env offline
######################################
# User Variables - Change as desired #
######################################
CNODE_HOSTNAME="node1.cardanoyyc.ca" # (Optional) Must resolve to the IP you are requesting from
CNODE_PORT="3000"
CNODE_VALENCY=1 # (Optional) for multi-IP hostnames
MAX_PEERS=10 # Maximum number of peers to return on successful fetch (note that a single peer may include valency of up to 3)
CUSTOM_PEERS="192.168.42.8:3000|192.168.42.9:3000" # *Additional* custom peers to (IP,port[,valency]) to add to your target topology.json
BATCH_AUTO_UPDATE=Y # Set to Y to automatically update the script if a new version is available without user interaction
######################################
# Do NOT modify code below #
######################################
PARENT="$(dirname $0)"
[[ -f "${PARENT}"/.env_branch ]] && BRANCH="$(cat ${PARENT}/.env_branch)" || BRANCH="master"
usage() {
cat <<-EOF
Usage: $(basename "$0") [-b <branch name>] [-f] [-p]
Topology Updater - Build topology with community pools
-f Disable fetch of a fresh topology file
-p Disable node alive push to Topology Updater API
-b Use alternate branch to check for updates - only for testing/development (Default: master)
EOF
exit 1
}
TU_FETCH='Y'
TU_PUSH='Y'
while getopts :fpb: opt; do
case ${opt} in
f ) TU_FETCH='N' ;;
p ) TU_PUSH='N' ;;
b ) echo "${OPTARG}" > "${PARENT}"/.env_branch ;;
\? ) usage ;;
esac
done
shift $((OPTIND -1))
[[ -z "${BATCH_AUTO_UPDATE}" ]] && BATCH_AUTO_UPDATE=N
#######################################################
# Version Check #
#######################################################
clear
if [[ ! -f "${PARENT}"/env ]]; then
echo -e "\nCommon env file missing: ${PARENT}/env"
echo -e "This is a mandatory prerequisite, please install with prereqs.sh or manually download from GitHub\n"
exit 1
fi
. "${PARENT}"/env offline &>/dev/null # ignore any errors, re-sourced later
if [[ "${UPDATE_CHECK}" == "Y" ]] && [[ "${BATCH_AUTO_UPDATE}" == "N" ]]; then
echo "Checking for script updates..."
# Check availability of checkUpdate function
if [[ ! $(command -v checkUpdate) ]]; then
echo -e "\nCould not find checkUpdate function in env, make sure you're using official guild docos for installation!"
exit 1
fi
# check for env update
! checkUpdate env ${BATCH_AUTO_UPDATE} && exit 1
! checkUpdate topologyUpdater.sh ${BATCH_AUTO_UPDATE} && exit 1
# source common env variables in case it was updated
. "${PARENT}"/env offline &>/dev/null
case $? in
0) : ;; # ok
2) echo "continuing with topology update..." ;;
*) exit 1 ;;
esac
fi
# Check if old style CUSTOM_PEERS with colon separator is used, if so convert to use commas
if [[ -n ${CUSTOM_PEERS} && ${CUSTOM_PEERS} != *","* ]]; then
CUSTOM_PEERS=${CUSTOM_PEERS//[:]/,}
fi
if [[ ${TU_PUSH} = "Y" ]]; then
fail_cnt=0
while ! blockNo=$(curl -s -f -m ${EKG_TIMEOUT} -H 'Accept: application/json' "http://${EKG_HOST}:${EKG_PORT}/" 2>/dev/null | jq -er '.cardano.node.metrics.blockNum.int.val //0' ); do
((fail_cnt++))
[[ ${fail_cnt} -eq 5 ]] && echo "5 consecutive EKG queries failed, aborting!"
echo "(${fail_cnt}/5) Failed to grab blockNum from node EKG metrics, sleeping for 30s before retrying... (ctrl-c to exit)"
sleep 30
done
fi
if [[ -n ${CNODE_HOSTNAME} && "${CNODE_HOSTNAME}" != "CHANGE ME" ]]; then
T_HOSTNAME="&hostname=${CNODE_HOSTNAME}"
else
T_HOSTNAME=''
fi
if [[ ${TU_PUSH} = "Y" ]]; then
if [[ ${IP_VERSION} = "4" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -4 "https://api.clio.one/htopology/v1/?port=${CNODE_PORT}&blockNo=${blockNo}&valency=${CNODE_VALENCY}&magic=${NWMAGIC}${T_HOSTNAME}" | tee -a "${LOG_DIR}"/topologyUpdater_lastresult.json
fi
if [[ ${IP_VERSION} = "6" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -6 "https://api.clio.one/htopology/v1/?port=${CNODE_PORT}&blockNo=${blockNo}&valency=${CNODE_VALENCY}&magic=${NWMAGIC}${T_HOSTNAME}" | tee -a "${LOG_DIR}"/topologyUpdater_lastresult.json
fi
fi
if [[ ${TU_FETCH} = "Y" ]]; then
if [[ ${IP_VERSION} = "4" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -4 -o "${TOPOLOGY}".tmp "https://api.clio.one/htopology/v1/fetch/?max=${MAX_PEERS}&magic=${NWMAGIC}&ipv=${IP_VERSION}"
else
curl -s -f -6 -o "${TOPOLOGY}".tmp "https://api.clio.one/htopology/v1/fetch/?max=${MAX_PEERS}&magic=${NWMAGIC}&ipv=${IP_VERSION}"
fi
if [[ -n "${CUSTOM_PEERS}" ]]; then
topo="$(cat "${TOPOLOGY}".tmp)"
IFS='|' read -ra cpeers <<< "${CUSTOM_PEERS}"
for cpeer in "${cpeers[@]}"; do
IFS=',' read -ra cpeer_attr <<< "${cpeer}"
case ${#cpeer_attr[@]} in
2) addr="${cpeer_attr[0]}"
port=${cpeer_attr[1]}
valency=1 ;;
3) addr="${cpeer_attr[0]}"
port=${cpeer_attr[1]}
valency=${cpeer_attr[2]} ;;
*) echo "ERROR: Invalid Custom Peer definition '${cpeer}'. Please double check CUSTOM_PEERS definition"
exit 1 ;;
esac
if [[ ${addr} = *.* ]]; then
! isValidIPv4 "${addr}" && echo "ERROR: Invalid IPv4 address or hostname '${addr}'. Please check CUSTOM_PEERS definition" && continue
elif [[ ${addr} = *:* ]]; then
! isValidIPv6 "${addr}" && echo "ERROR: Invalid IPv6 address '${addr}'. Please check CUSTOM_PEERS definition" && continue
fi
! isNumber ${port} && echo "ERROR: Invalid port number '${port}'. Please check CUSTOM_PEERS definition" && continue
! isNumber ${valency} && echo "ERROR: Invalid valency number '${valency}'. Please check CUSTOM_PEERS definition" && continue
topo=$(jq '.Producers += [{"addr": $addr, "port": $port|tonumber, "valency": $valency|tonumber}]' --arg addr "${addr}" --arg port ${port} --arg valency ${valency} <<< "${topo}")
done
echo "${topo}" | jq -r . >/dev/null 2>&1 && echo "${topo}" > "${TOPOLOGY}".tmp
fi
mv "${TOPOLOGY}".tmp "${TOPOLOGY}"
fi
exit 0
And the resulting mainnet-topology.json for Node 1
{
"resultcode": "201",
"networkMagic": "764824073",
"ipType": 4,
"requestedIpVersion": "4",
"max": "10",
"Producers": [
{
"addr": "adarelay02.psilobyte.io",
"port": 3002,
"valency": 1,
"distance": 282,
"continent": "NA",
"country": "CA",
"region": "AB"
},
{
"addr": "relay0.8sqrdpools.com",
"port": 6000,
"valency": 1,
"distance": 1921,
"continent": "NA",
"country": "US",
"region": "CA"
},
{
"addr": "3.18.168.22",
"port": 6000,
"valency": 1,
"distance": 2671,
"continent": "NA",
"country": "US",
"region": "OH"
},
{
"addr": "54.159.255.195",
"port": 6000,
"valency": 1,
"distance": 3110,
"continent": "NA",
"country": "US",
"region": "VA"
},
{
"addr": "75.119.133.13",
"port": 3000,
"valency": 1,
"distance": 3947,
"continent": "NA",
"country": "US",
"region": "FL"
},
{
"addr": "antrel.dyn.ydns.io",
"port": 54833,
"valency": 1,
"distance": 7158,
"continent": "EU",
"country": "NL",
"region": "NH"
},
{
"addr": "94.237.99.68",
"port": 8001,
"valency": 1,
"distance": 7512,
"continent": "EU",
"country": "FI",
"region": "HE"
},
{
"addr": "157.90.119.14",
"port": 6000,
"valency": 1,
"distance": 7687,
"continent": "EU",
"country": "DE",
"region": "BY"
},
{
"addr": "207.180.243.108",
"port": 6000,
"valency": 1,
"distance": 7815,
"continent": "EU",
"country": "DE",
"region": "BY"
},
{
"addr": "34.80.179.174",
"port": 6000,
"valency": 1,
"distance": 9952,
"continent": "AS",
"country": "TW",
"region": "CYI"
},
{
"addr": "192.168.42.8",
"port": 3000,
"valency": 1
},
{
"addr": "192.168.42.9",
"port": 3000,
"valency": 1
}
]
}
Here is the topologyUpdater.sh for node 2
#!/usr/bin/env bash
# shellcheck disable=SC2086,SC2034
# shellcheck source=/dev/null
PARENT="$(dirname $0)"
[[ -f "${PARENT}"/env ]] && . "${PARENT}"/env offline
######################################
# User Variables - Change as desired #
######################################
CNODE_HOSTNAME="node2.cardanoyyc.ca" # (Optional) Must resolve to the IP you are requesting from
CNODE_PORT="3006"
CNODE_VALENCY=1 # (Optional) for multi-IP hostnames
MAX_PEERS=8 # Maximum number of peers to return on successful fetch (note that a single peer may include valency of up to 3)
CUSTOM_PEERS="192.168.42.6:3000|192.168.42.9:3000" # *Additional* custom peers to (IP,port[,valency]) to add to your target topology.json
BATCH_AUTO_UPDATE=Y # Set to Y to automatically update the script if a new version is available without user interaction
######################################
# Do NOT modify code below #
######################################
PARENT="$(dirname $0)"
[[ -f "${PARENT}"/.env_branch ]] && BRANCH="$(cat ${PARENT}/.env_branch)" || BRANCH="master"
usage() {
cat <<-EOF
Usage: $(basename "$0") [-b <branch name>] [-f] [-p]
Topology Updater - Build topology with community pools
-f Disable fetch of a fresh topology file
-p Disable node alive push to Topology Updater API
-b Use alternate branch to check for updates - only for testing/development (Default: master)
EOF
exit 1
}
TU_FETCH='Y'
TU_PUSH='Y'
while getopts :fpb: opt; do
case ${opt} in
f ) TU_FETCH='N' ;;
p ) TU_PUSH='N' ;;
b ) echo "${OPTARG}" > "${PARENT}"/.env_branch ;;
\? ) usage ;;
esac
done
shift $((OPTIND -1))
[[ -z "${BATCH_AUTO_UPDATE}" ]] && BATCH_AUTO_UPDATE=N
#######################################################
# Version Check #
#######################################################
clear
if [[ ! -f "${PARENT}"/env ]]; then
echo -e "\nCommon env file missing: ${PARENT}/env"
echo -e "This is a mandatory prerequisite, please install with prereqs.sh or manually download from GitHub\n"
exit 1
fi
. "${PARENT}"/env offline &>/dev/null # ignore any errors, re-sourced later
if [[ "${UPDATE_CHECK}" == "Y" ]] && [[ "${BATCH_AUTO_UPDATE}" == "N" ]]; then
echo "Checking for script updates..."
# Check availability of checkUpdate function
if [[ ! $(command -v checkUpdate) ]]; then
echo -e "\nCould not find checkUpdate function in env, make sure you're using official guild docos for installation!"
exit 1
fi
# check for env update
! checkUpdate env ${BATCH_AUTO_UPDATE} && exit 1
! checkUpdate topologyUpdater.sh ${BATCH_AUTO_UPDATE} && exit 1
# source common env variables in case it was updated
. "${PARENT}"/env offline &>/dev/null
case $? in
0) : ;; # ok
2) echo "continuing with topology update..." ;;
*) exit 1 ;;
esac
fi
# Check if old style CUSTOM_PEERS with colon separator is used, if so convert to use commas
if [[ -n ${CUSTOM_PEERS} && ${CUSTOM_PEERS} != *","* ]]; then
CUSTOM_PEERS=${CUSTOM_PEERS//[:]/,}
fi
if [[ ${TU_PUSH} = "Y" ]]; then
fail_cnt=0
while ! blockNo=$(curl -s -f -m ${EKG_TIMEOUT} -H 'Accept: application/json' "http://${EKG_HOST}:${EKG_PORT}/" 2>/dev/null | jq -er '.cardano.node.metrics.blockNum.int.val //0' ); do
((fail_cnt++))
[[ ${fail_cnt} -eq 5 ]] && echo "5 consecutive EKG queries failed, aborting!"
echo "(${fail_cnt}/5) Failed to grab blockNum from node EKG metrics, sleeping for 30s before retrying... (ctrl-c to exit)"
sleep 30
done
fi
if [[ -n ${CNODE_HOSTNAME} && "${CNODE_HOSTNAME}" != "CHANGE ME" ]]; then
T_HOSTNAME="&hostname=${CNODE_HOSTNAME}"
else
T_HOSTNAME=''
fi
if [[ ${TU_PUSH} = "Y" ]]; then
if [[ ${IP_VERSION} = "4" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -4 "https://api.clio.one/htopology/v1/?port=${CNODE_PORT}&blockNo=${blockNo}&valency=${CNODE_VALENCY}&magic=${NWMAGIC}${T_HOSTNAME}" | tee -a "${LOG_DIR}"/topologyUpdater_lastresult.json
fi
if [[ ${IP_VERSION} = "6" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -6 "https://api.clio.one/htopology/v1/?port=${CNODE_PORT}&blockNo=${blockNo}&valency=${CNODE_VALENCY}&magic=${NWMAGIC}${T_HOSTNAME}" | tee -a "${LOG_DIR}"/topologyUpdater_lastresult.json
fi
fi
if [[ ${TU_FETCH} = "Y" ]]; then
if [[ ${IP_VERSION} = "4" || ${IP_VERSION} = "mix" ]]; then
curl -s -f -4 -o "${TOPOLOGY}".tmp "https://api.clio.one/htopology/v1/fetch/?max=${MAX_PEERS}&magic=${NWMAGIC}&ipv=${IP_VERSION}"
else
curl -s -f -6 -o "${TOPOLOGY}".tmp "https://api.clio.one/htopology/v1/fetch/?max=${MAX_PEERS}&magic=${NWMAGIC}&ipv=${IP_VERSION}"
fi
if [[ -n "${CUSTOM_PEERS}" ]]; then
topo="$(cat "${TOPOLOGY}".tmp)"
IFS='|' read -ra cpeers <<< "${CUSTOM_PEERS}"
for cpeer in "${cpeers[@]}"; do
IFS=',' read -ra cpeer_attr <<< "${cpeer}"
case ${#cpeer_attr[@]} in
2) addr="${cpeer_attr[0]}"
port=${cpeer_attr[1]}
valency=1 ;;
3) addr="${cpeer_attr[0]}"
port=${cpeer_attr[1]}
valency=${cpeer_attr[2]} ;;
*) echo "ERROR: Invalid Custom Peer definition '${cpeer}'. Please double check CUSTOM_PEERS definition"
exit 1 ;;
esac
if [[ ${addr} = *.* ]]; then
! isValidIPv4 "${addr}" && echo "ERROR: Invalid IPv4 address or hostname '${addr}'. Please check CUSTOM_PEERS definition" && continue
elif [[ ${addr} = *:* ]]; then
! isValidIPv6 "${addr}" && echo "ERROR: Invalid IPv6 address '${addr}'. Please check CUSTOM_PEERS definition" && continue
fi
! isNumber ${port} && echo "ERROR: Invalid port number '${port}'. Please check CUSTOM_PEERS definition" && continue
! isNumber ${valency} && echo "ERROR: Invalid valency number '${valency}'. Please check CUSTOM_PEERS definition" && continue
topo=$(jq '.Producers += [{"addr": $addr, "port": $port|tonumber, "valency": $valency|tonumber}]' --arg addr "${addr}" --arg port ${port} --arg valency ${valency} <<< "${topo}")
done
echo "${topo}" | jq -r . >/dev/null 2>&1 && echo "${topo}" > "${TOPOLOGY}".tmp
fi
mv "${TOPOLOGY}".tmp "${TOPOLOGY}"
fi
exit 0
And the mainnet-topology.json for Node 2
{
"resultcode": "201",
"networkMagic": "764824073",
"ipType": 4,
"requestedIpVersion": "4",
"max": "8",
"Producers": [
{
"addr": "adarelay02.psilobyte.io",
"port": 3002,
"valency": 1,
"distance": 282,
"continent": "NA",
"country": "CA",
"region": "AB"
},
{
"addr": "relay0.8sqrdpools.com",
"port": 6000,
"valency": 1,
"distance": 1921,
"continent": "NA",
"country": "US",
"region": "CA"
},
{
"addr": "3.18.168.22",
"port": 6000,
"valency": 1,
"distance": 2671,
"continent": "NA",
"country": "US",
"region": "OH"
},
{
"addr": "54.159.255.195",
"port": 6000,
"valency": 1,
"distance": 3110,
"continent": "NA",
"country": "US",
"region": "VA"
},
{
"addr": "75.119.133.13",
"port": 3000,
"valency": 1,
"distance": 3947,
"continent": "NA",
"country": "US",
"region": "FL"
},
{
"addr": "antrel.dyn.ydns.io",
"port": 54833,
"valency": 1,
"distance": 7158,
"continent": "EU",
"country": "NL",
"region": "NH"
},
{
"addr": "94.237.99.68",
"port": 8001,
"valency": 1,
"distance": 7512,
"continent": "EU",
"country": "FI",
"region": "HE"
},
{
"addr": "157.90.119.14",
"port": 6000,
"valency": 1,
"distance": 7687,
"continent": "EU",
"country": "DE",
"region": "BY"
},
{
"addr": "192.168.42.6",
"port": 3000,
"valency": 1
},
{
"addr": "192.168.42.9",
"port": 3000,
"valency": 1
}
]
}