Skip to content

Commit

Permalink
update docker script
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickwieth committed Dec 20, 2023
1 parent 8a3896e commit 1b65d77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
62 changes: 32 additions & 30 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

echo -e "\033[0;32mfasten your seatbelts\033[0m"
FAUCET_SECRET_KEY="0x6F1f5bd93f3D59d6eed1d5ec40E29C1821029759"
CHAIN_ID=Cardchain
USE_SNAP=true
USE_SNAP=false

if [ -z "$FAUCET_SECRET_KEY" ]
then
Expand Down Expand Up @@ -49,36 +48,39 @@ SEEDS=""
echo "peers is:" $PEERS
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.Cardchain/config/config.toml

mapfile -t snap_rpcs < <(
jq -r '.snap_rpcs[]' peer_nodes.json
)

for i in "${snap_rpcs[@]}"; do
if curl --output /dev/null --silent --head --fail --connect-timeout 5 $i; then
echo "URL exists: $i"
SNAP_RPC=$i
break
else
echo "not reachable $i"
fi
done
if [ -z "$SNAP_RPC" ]
then
echo -e "\033[0;31mNo SNAP_RPC available\033[0m"
exit
if [ -z $USE_SNAP ] then

mapfile -t snap_rpcs < <(
jq -r '.snap_rpcs[]' peer_nodes.json
)

for i in "${snap_rpcs[@]}"; do
if curl --output /dev/null --silent --head --fail --connect-timeout 5 $i; then
echo "URL exists: $i"
SNAP_RPC=$i
break
else
echo "not reachable $i"
fi
done
if [ -z "$SNAP_RPC" ]
then
echo -e "\033[0;31mNo SNAP_RPC available\033[0m"
exit
fi

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height)
echo $LATEST_HEIGHT
BLOCK_HEIGHT=$((LATEST_HEIGHT)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo -e "\033[0;36mlatest height: $LATEST_HEIGHT \nblock height: $BLOCK_HEIGHT \ntrust hash: $TRUST_HASH \033[0m"

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.Cardchain/config/config.toml; \
fi

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height)
echo $LATEST_HEIGHT
BLOCK_HEIGHT=$((LATEST_HEIGHT)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo -e "\033[0;36mlatest height: $LATEST_HEIGHT \nblock height: $BLOCK_HEIGHT \ntrust hash: $TRUST_HASH \033[0m"

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.Cardchain/config/config.toml; \

# config pruning
indexer="kv"
pruning="custom"
Expand Down
1 change: 1 addition & 0 deletions peer_nodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"https://rpc-testnet-cardchain.nodeist.net"
],
"peers": [
"http://202.61.225.157:26656",
"cardchain-testnet-peer.itrocket.net:31656",
"crowd.peer.stavr.tech:21206",
"rpc-testnet-cardchain.nodeist.net:26656"
Expand Down

0 comments on commit 1b65d77

Please sign in to comment.