Skip to content

Instantly share code, notes, and snippets.

@aimxhaisse
Last active April 22, 2021 13:26
Show Gist options
  • Save aimxhaisse/b57d28d529497f5a252162a7abdf776a to your computer and use it in GitHub Desktop.
Save aimxhaisse/b57d28d529497f5a252162a7abdf776a to your computer and use it in GitHub Desktop.
Shell script helper to compute the legacyCodec param for Pocket 0.6's protocol upgrade
#!/usr/bin/env bash
#
# Requirements: have JQ somehow installed.
FULL_NODE="url_to_your_full_node"
# Best-effort solution to get the status of the gov/upgrade parameter
# and infer whether or not we should use the legacy codec in Pocket
# CLI. If some error was found during the process (timeout on the full
# node, unexpected parsing error), assume we use the legacy codec.
function get_legacy_codec_param {
local is_upgraded=$(pocket query params --remoteCLIURL=${FULL_NODE} | tail +2 | jq '.gov_params[] | select(.param_key=="gov/upgrade") | .param_value | fromjson | .value.Height != "0"')
if [ "${is_upgraded}" == "true" ]
then
echo "false"
else
# This is a best-effort solution, 'is_upgraded' can be null or
# a strange value if there was some issue while getting the
# status on the blockchain, by default, use the legacy codec.
echo "true"
fi
}
# pocket nodes stake ... legacyCodec=$(get_legacy_codec_param)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment