99 exit
1010fi
1111
12+
13+ # functions
14+ find_current_data_version () {
15+ ver=0
16+ ver=$( curl -s " https://snapshot.notional.ventures/$chain_name /chain.json" | jq -r ' .data_version // 0' )
17+ echo $ver
18+ }
19+
20+
21+
1222cd $HOME
1323
1424pacman -Syu --noconfirm
15- pacman -S --noconfirm base-devel dnsutils python caddy logrotate screen
25+ pacman -S --noconfirm base-devel jq dnsutils python caddy logrotate screen
1626
1727echo " read chain info:"
1828eval " $( curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/data/chain_registry.ini | awk -v TARGET=$chain_name -F ' = ' '
@@ -31,25 +41,30 @@ echo "json_rpc=$json_rpc"
3141# #######################################################################################################################
3242# dynamic upstream
3343
44+ # get the data version from chain.json, service name is rpc_$chain_name_$version
45+ data_version=$( find_current_data_version)
46+ rpc_service_name=" rpc_${chain_name} _${data_version} "
47+ echo " rpc_service_name=$rpc_service_name "
48+
3449CONFIG_FILE=" /etc/caddy/Caddyfile"
3550TMP_CONFIG_FILE=" /etc/caddy/Caddyfile.tmp"
3651
3752# functions
3853generate_new_upstream_config () {
3954 # use dig to figure out IPs of service
40- new_ips=$( dig +short " tasks.$chain_name " | sort)
55+ new_ips=$( dig +short " tasks.$rpc_service_name " | sort)
4156
4257 rpc_str=" "
4358 api_str=" "
4459 ws_str=" "
4560 grpc_str=" "
4661 jsonrpc_str=" "
4762 if [[ -z " $new_ips " ]]; then
48- rpc_str=" to http://$chain_name "
49- api_str=" to http://$chain_name :1317"
50- ws_str=" to http://$chain_name "
51- grpc_str=" to http://$chain_name :9090"
52- jsonrpc_str=" to http://$chain_name :8545"
63+ rpc_str=" to http://$rpc_service_name "
64+ api_str=" to http://$rpc_service_name :1317"
65+ ws_str=" to http://$rpc_service_name "
66+ grpc_str=" to http://$rpc_service_name :9090"
67+ jsonrpc_str=" to http://$rpc_service_name :8545"
5368 else
5469 while read -r ip_addr || [[ -n $ip_addr ]]; do
5570 if [[ -z " $rpc_str " ]]; then
0 commit comments