Skip to content

Commit

Permalink
Improve find_block_60_days_ago.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Dec 12, 2023
1 parent 9c25a56 commit 7d673c4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions devtools/release/find_block_60_days_ago.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ function get_60days_ago_block(){
echo ${START_NUMBER}
}

MAINNET_ASSUME_TARGET_HEIGHT=$(get_60days_ago_block https://mainnet.ckb.dev)
MAINNET_ASSUME_TARGET_HASH=$(get_block_hash https://mainnet.ckb.dev ${MAINNET_ASSUME_TARGET_HEIGHT})
MAINNET_ASSUME_TARGET_TIMESTAMP=$(get_block_timestamp https://mainnet.ckb.dev ${MAINNET_ASSUME_TARGET_HEIGHT})
MAINNET_ASSUME_TARGET_DATE=$(date -d @$((${MAINNET_ASSUME_TARGET_TIMESTAMP} / 1000)))


TESTNET_ASSUME_TARGET_HEIGHT=$(get_60days_ago_block https://testnet.ckb.dev)
TESTNET_ASSUME_TARGET_HASH=$(get_block_hash https://testnet.ckb.dev ${TESTNET_ASSUME_TARGET_HEIGHT})
TESTNET_ASSUME_TARGET_TIMESTAMP=$(get_block_timestamp https://testnet.ckb.dev ${TESTNET_ASSUME_TARGET_HEIGHT})
TESTNET_ASSUME_TARGET_DATE=$(date -d @$((${TESTNET_ASSUME_TARGET_TIMESTAMP} / 1000)))

printf "today: %s\n\n" "$(date)"
function print_60_days_ago_block(){
local host=$1
ASSUME_TARGET_HEIGHT=$(get_60days_ago_block ${host})
ASSUME_TARGET_HASH=$(get_block_hash ${host} ${ASSUME_TARGET_HEIGHT})
ASSUME_TARGET_TIMESTAMP=$(get_block_timestamp ${host} ${ASSUME_TARGET_HEIGHT})
ASSUME_TARGET_DATE=$(date -d @$((${ASSUME_TARGET_TIMESTAMP} / 1000)))
printf "the 60 days ago block is: %d %s in %s\n" ${ASSUME_TARGET_HEIGHT} ${ASSUME_TARGET_HASH} "${ASSUME_TARGET_DATE}"
}

printf "mainnet: the 60 days ago block is: %d %s in %s\n" ${MAINNET_ASSUME_TARGET_HEIGHT} ${MAINNET_ASSUME_TARGET_HASH} "${MAINNET_ASSUME_TARGET_DATE}"
printf "testnet: the 60 days ago block is: %d %s in %s\n" ${TESTNET_ASSUME_TARGET_HEIGHT} ${TESTNET_ASSUME_TARGET_HASH} "${MAINNET_ASSUME_TARGET_DATE}"
printf "Now: %s\n\n" "$(date)"
printf "Finding the 60 days ago block..., this script may take 1 minute\n\n"
printf "MainNet:\n"
print_60_days_ago_block https://mainnet.ckb.dev
printf "TestNet:\n"
print_60_days_ago_block https://testnet.ckb.dev

0 comments on commit 7d673c4

Please sign in to comment.