奇亚(Chia, XCH) 接口之获取主链相关信息,主要是获取当前块高,调用的路径为 /get_blockchain_state
参数则传递空 JSON 即可 {}
例如
curl --insecure --cert ~/.chia/mainnet/config/ssl/full_node/private_full_node.crt --key ~/.chia/mainnet/config/ssl/full_node/private_full_node.key -d '{}' -H "Content-Type: application/json" -X POST https://localhost:8555/get_blockchain_state | python3 -m json.tool
备注,后面的
|python3 -m json.tool
主要是用于美化返回值
返回的结果为
{ "blockchain_state": { "difficulty": 700, "genesis_challenge_initialized": true, "mempool_size": 7, "peak": { "challenge_block_info_hash": "0xabeb5fa0c2d07e7763ea5a413cc86723b555cd52fc68de739f989ee04e5143fc", "challenge_vdf_output": { "data": "0x0000f2c86ab1981b249a47d08a018233c4158bd23f7637b24ef140def7522776f105faedfdee8362b4a82180d5beffcb25eefa437fe2c523b002b8ee04041a03c111dd7a258707796c4baadd502570a30f4a88506cc233ad2e90c2542e8d8d00c8200100" }, "deficit": 0, "farmer_puzzle_hash": "0x907491ca39c35bc1f9a6eda33f7c0f97a9f583975088dad7216f1edd79f522ae", "fees": null, "finished_challenge_slot_hashes": null, "finished_infused_challenge_slot_hashes": null, "finished_reward_slot_hashes": null, "header_hash": "0xccd0938f8605cea8a0d482d77ca83154ee8ded62af19a2058643babf99fda18a", "height": 329490, "infused_challenge_vdf_output": { "data": "0x0000500c9f8a8034e424f06ecfdd5fdc11bbc828025d06828102f0a9eab3d60c35ab8c29ec009b4085a0082689329bd2885b49446866ffe5ebdccf942c0c839df1723d8c1ff05266226c55b65c09ceae7bb80dade1c882ba32323b5c85ca717d8b060100" }, "overflow": false, "pool_puzzle_hash": "0x907491ca39c35bc1f9a6eda33f7c0f97a9f583975088dad7216f1edd79f522ae", "prev_hash": "0x6b036f3ccb357db391da80e37d01adcfc81db61edff15315c9126da0950c9e3f", "prev_transaction_block_hash": null, "prev_transaction_block_height": 329487, "required_iters": 160829, "reward_claims_incorporated": null, "reward_infusion_new_challenge": "0xa6de1378705e4808236e006a161a4f77886da2c200df04cd8fc925e8cc255e1a", "signage_point_index": 22, "sub_epoch_summary_included": null, "sub_slot_iters": 113246208, "timestamp": null, "total_iters": 1066881872957, "weight": 40274260 }, "space": 11550819449751812096, "sub_slot_iters": 113246208, "sync": { "sync_mode": false, "sync_progress_height": 0, "sync_tip_height": 0, "synced": true } }, "success": true }
里面有几个参数很重要:
- 一个是返回的是否包含错误,如果
"success"
字段为true
则结果正确 - 一个是
blockchain_state/sync/synced
参数,表示当前节点是否已经同步完毕,如果同步完毕则true
- 一个是
blockchain_state/peak/header_hash
参数,表示当前最新区块的区块哈希,你可以理解为编号 - 一个是
blockchain_state/peak/height
参数,表示当前最新的块高
其它参数就看你自己的需要与否了
目前尚无回复