# State sync

sudo systemctl stop gitopiad

SNAP\_RPC="<https://gitopia>......"; \\

LATEST\_HEIGHT=$(curl -s $SNAP\_RPC/block | jq -r .result.block.header.height); \\

BLOCK\_HEIGHT=$((LATEST\_HEIGHT - 2000)); \\

TRUST\_HASH=$(curl -s "$SNAP\_RPC/block?height=$BLOCK\_HEIGHT" | jq -r .result.block\_id.hash); \\

echo $LATEST\_HEIGHT $BLOCK\_HEIGHT $TRUST\_HASH

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/.gitopia/config/config.toml

&& sed -i.bak -e "s/^persistent\_peers \*=.\*/persistent\_peers = \\"$peers\\"/" $HOME/.gitopia/config/config.toml

gitopiad tendermint unsafe-reset-all --home \~/.gitopia && sudo systemctl restart gitopiad && journalctl -u gitopiad -f --output cat
