Last active
February 16, 2021 21:27
-
-
Save gotjoshua/9dd958d45bdcfd1ac4ae5f11a873653b to your computer and use it in GitHub Desktop.
txMemoCountForBlock.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BLOCK_HEIGHT=${1:-42672} # the block with most txs during the stress test | |
eachPage=1 | |
# escaping syntax from https://pkg.go.dev/github.com/qredo/tendermint/rpc/core#TxSearch | |
CMD="regen query txs --events 'tx.height=${BLOCK_HEIGHT}' --limit 100 --page=${eachPage}" | |
echo 'First Page:' | |
echo "$CMD | jq ." | |
RESULT=$(eval $CMD) | |
MEMOS=$(echo $RESULT | jq -r '.txs[].tx.body.memo') | |
COUNT=$(echo $RESULT | jq -r '.total_count') | |
PAGES=$(( (COUNT + 100 - 1 ) / 100 )) # works because bash has no floating point https://stackoverflow.com/a/2395027/2919380 | |
echo -en "page 1" | |
if [[ $PAGES -gt 1 ]]; then | |
RANGE=$(eval echo {2..$PAGES}) | |
for eachPage in $RANGE; do | |
echo -en "\b\b..page ${eachPage}" | |
CMD="regen query txs --events 'tx.height=${BLOCK_HEIGHT}' --limit 100 --page=${eachPage}" | |
RESULT=$(eval $CMD) | |
MEMOS+=$(echo $RESULT | jq -r '.txs[].tx.body.memo') | |
done | |
fi | |
echo -e "\n\n Block: $BLOCK_HEIGHT Total Txs: $COUNT " | |
MEMOS=($(echo $MEMOS)) | |
(IFS=$'\n'; sort <<< "${MEMOS[*]}") | uniq -c | grep -v '1 ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hopefully the sdk will make this easier soon:
cosmos/cosmos-sdk#8579