git.delta.rocks / unique-network / refs/commits / f48afb4f7913

difftreelog

source

js-packages/scripts/wait_for_first_block.sh1.0 KiBsourcehistory
1#!/usr/bin/env bash23DIR=$(dirname "$0")45. "$DIR/generate_types/functions.sh"67last_block_id=08block_id=09counter=010function get_block {11    block_id_hex=$(do_rpc chain_getHeader | jq -r .result.number)12    block_id=$((block_id_hex))13    echo Id = $block_id14}1516function had_new_block {17    last_block_id=$block_id18    get_block19    if (( last_block_id != 0 && block_id > last_block_id )); then20        return 021    fi22    return 123}2425function reset_check {26    last_block_id=027    block_id=028    counter=029}3031while ! had_new_block ; do32    echo "Waiting for another block..."33    counter=$((counter+1))34    echo "counter="$counter35    sleep 1236    if [ $counter -gt 400 ]; then37        exit 1;38    fi39done4041reset_check4243echo "Chain is running, but lets wait for another block after a minute, to avoid startup flakiness."44sleep 604546while ! had_new_block ; do47    echo "Waiting for another block..."48    counter=$((counter+1))49    echo "counter="$counter50    sleep 1251    if [ $counter -gt 400 ]; then52        exit 1;53    fi54done555657echo "Chain is running!"