I send rpc calls to a node through tezos-client
and I would like to know the length, or the height, of the blockchain so I can see if it is synced and, if not, how much time is remaining. How do I do that?
2 Answers
tezos-client rpc get /chains/main/blocks/head
. Look for the value of the level
key under the header
key in the outputted json.
The output data is quite big, so you can use this:
tezos-client rpc get /chains/main/blocks/head | grep level | head -1
-
1Since all output of the RPC is JSON, you should look into using
jq
rather than grep/head. Far more powerful for command-line filtering.– utdrmac ♦Jul 16, 2020 at 19:01
You can also call tezos-client get timestamp
repeatedly: it will give you the timestamp of the most recently received block. You'll get an idea on where you're at and how long you have left to synchronize. If you want to synchronize the full state of the blockchain, this might take a long time. Look into snapshots to get into sync faster. You can find snapshots here.