只需要请求/v1/chain/get_info
从eos源代码得知head_block_id是由ref_block_prefix和ref_block_num经过hash拼接而成
请求 https://mainnet-eos…/v1/chain/get_info
返回
{
server_version: "b312faa4",
chain_id: "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
head_block_num: 65476388,
last_irreversible_block_num: 65476059,
last_irreversible_block_id: "03e715db8e46880c00ce7a03725380dc085736361ede1a72b44c53ed333aedf0",
head_block_id: "03e71724eff1698cf8b381ae8f97964536f147e1e83205ca67cade1bc8ce53b0",
head_block_time: "2019-06-26T05:36:20.000",
head_block_producer: "atticlabeosb",
virtual_block_cpu_limit: 200000000,
virtual_block_net_limit: 1048576000,
block_cpu_limit: 43827,
block_net_limit: 1040264,
server_version_string: "mainnet-1.5.1-dirty"
}
解析head_block_id
AsciiToHex((u8 *) head_block_id.substr(0, 8).c_str(), block_num, 8);
AsciiToHex((u8 *) head_block_id.substr(16, 24).c_str(), block_prefix, 8);
ref_block_num = ((block_num[0] & 0xFF) << 24) |
((block_num[1] & 0xFF) << 16) |
((block_num[2] & 0xFF) << 8) |
((block_num[3] & 0xFF) << 0);
ref_block_prefix =
(u32((block_prefix[0] & 0xFF))) |
(u32((block_prefix[1] & 0xFF) << 8)) |
(u32((block_prefix[2] & 0xFF) << 16)) |
(u32((block_prefix[3] & 0xFF) << 24));