Could not find method get_block_range
I am trying to build a tool for Hive, and as always, I run into problems.
Developing anything for Hive is a complete pain.
Here's a description of today's problem:
block_api.get_block
Trying to isolate the problem, I come up with this:
<!DOCTYPE html>
<html>
<script>
var block_num = 50000000
fetch('https://anyx.io', {method: "POST", body: JSON.stringify({
"id":1,
"jsonrpc":"2.0",
"method":"call",
"params":[
"block_api",
"get_block",
[block_num]
]
})})
.then(response => response.json())
.then(response =>{
console.log(response)
});
</script>
</html>
...works fine:
...but I want more than one block.
block_api.get_block_range
Same code, different method:
<!DOCTYPE html>
<html>
<script>
var block_num = 50000000
fetch('https://anyx.io', {method: "POST", body: JSON.stringify({
"id":1,
"jsonrpc":"2.0",
"method":"call",
"params":[
"block_api",
"get_block_range",
[block_num, 10]
]
})})
.then(response => response.json())
.then(response =>{
console.log(response)
});
</script>
</html>
Result:
Could not find method get_block_range
Could not find method get_block_range
The journey begins.
I google get_block_range hive
and am surprised to find good results, despite Hive having the worst possible name for any project on the internet.
Hive Developer Portal
get_block: https://developers.hive.io/apidefinitions/#block_api.get_block
get_block_range: https://developers.hive.io/apidefinitions/#block_api.get_block_range
It uses different parameters, but the rest of the usage is identical.
According to that, I have done everything correctly. It just does not work.
So much for the Developer Portal.
...Further down in my google results I find a post by blocktrades, where he mentions get_block_range
working on his nodes, 8 months ago.
@blocktrades/hive-api-node-performance-measurement
I try different nodes:
Could not find method get_block_range
I do more research and check through the hive-js code:
{
"api": "condenser_api",
"method": "get_block_header",
"params": ["block_num"]
},
{
"api": "block_api",
"method": "get_block",
"params": ["block_num"]
},
https://gitlab.syncad.com/hive/hive-js/-/blob/master/src/api/methods.js#L77
So get_block_header
is a method of condenser_api
, not block_api
?
Now I am even more confused, as the Hive Developer Portal states differently:
https://developers.hive.io/apidefinitions/#block_api.get_block_header
For good measure, I try all APIs for the get_block_range
method.
Could not find method get_block_range
The only code example containing 'blocks' I can find is this:
https://developers.hive.io/tutorials-javascript/stream_blockchain_transactions.html
I get absolutely 0 use out of that tutorial and decide to write a post about how stupid this is.
Am I making a mistake somewhere? Am I the only person to ever use get_block_range
?
So I am searching beem to see how it works there:
blocks = self.blockchain.rpc.get_block_range({'starting_block_num': starting_block_num, "count": count}, api="block")['blocks']
That looks familiar! So I check its usage here:
https://beem.readthedocs.io/en/latest/beem.block.html#beem.block.Blocks
Obtain a list of blocks
Parameters:
name_list (list) – list of accounts to fetch
count (int) – (optional) maximum number of accounts to fetch per call, defaults to 100
blockchain_instance (Steem/Hive) – Steem() or Hive() instance to use when accessing a RPCcreator = Account(creator, blockchain_instance=self)
List of accounts to fetch? Why accounts?
If you are lucky enough to find commented code around Hive, the comment is either confusing or just wrong half of the time, it feels.
...at least it looks like beem is using the block_api
.
I am no wiser, as beem is using the rpc call pretty much the same as I do.
I am too frustrated to continue at this point.
That was my day developing a tool for Hive: No progress at all. Just hours of: