From b168d6efb53c00953f3b6bd587488a91ee8ea9e8 Mon Sep 17 00:00:00 2001 From: K-Dimentional Tree Date: Fri, 23 Aug 2024 17:13:29 +0300 Subject: [PATCH] Added method getBlockTransactionsExt --- README.md | 5 +++ scripts/update_init_block.sh | 66 +++++++++++++++++++++++++++++++++ ton-http-api/.docker/Dockerfile | 2 +- ton-http-api/pyTON/main.py | 18 +++++++++ ton-http-api/pyTON/manager.py | 3 ++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100755 scripts/update_init_block.sh diff --git a/README.md b/README.md index 46454a0..345d697 100644 --- a/README.md +++ b/README.md @@ -159,3 +159,8 @@ To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LIT Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib). - Docker Compose: `docker-compose build --no-cache`. - Local run: `pip install -U ton-http-api`. + +### No working liteservers error. + +Usually, liteservers from the config has already deleted the block, which specified in `init_block` section. +To update init block, please **backup your config file** and run script `./scripts/update_init_block.sh private/mainnet.json`. For testnet add flag `--testnet`. diff --git a/scripts/update_init_block.sh b/scripts/update_init_block.sh new file mode 100755 index 0000000..ac50978 --- /dev/null +++ b/scripts/update_init_block.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +ENDPOINT=https://toncenter.com/api/v2 + + +function usage() { + echo 'required 1 positional argument: name of config file' + echo 'Supported argumets:' + echo ' -h --help Show this message' + echo ' --testnet Use testnet endpoint' + exit +} + + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + usage + exit 1 + ;; + --testnet) + ENDPOINT=https://testnet.toncenter.com/api/v2 + shift + ;; + -*|--*) + echo "Error: unknown option $1" + usage + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +set -- "${POSITIONAL_ARGS[@]}" + +# main logic +LAST_SEQNO=$(curl -s ${ENDPOINT}/getMasterchainInfo | jq ".result.last.seqno") +echo "Last seqno is $LAST_SEQNO" + +sleep 1 +LAST_KEYBLOCK_SEQNO=$(curl -s "${ENDPOINT}/getBlockHeader?workchain=-1&shard=-9223372036854775808&seqno=${LAST_SEQNO}" | jq .result.prev_key_block_seqno) +echo "Last keyblock seqno is $LAST_KEYBLOCK_SEQNO" + +sleep 1 +RES=$(curl -s "${ENDPOINT}/lookupBlock?workchain=-1&shard=-9223372036854775808&seqno=${LAST_KEYBLOCK_SEQNO}" | jq .result ) + +SEQNO=$(echo "$RES" | jq '.seqno') +FILEHASH=$(echo "$RES" | jq '.file_hash') +ROOTHASH=$(echo "$RES" | jq '.root_hash') + +FILENAME=$1 +python3 <