RPC get a table rows, is work bad!
Details: Summary: Using eos RPC to get blockchain table data, the return data is not follow the condition!
Description: I get the voters table data again by again, but it's add just a little row in the table, and it not return all data any time!
Steps To Reproduce:
- I use the script to get table rows, it not be get all!
more = True
lens = -1
while more:
data = {"scope":"eosio", "code":"eosio", "table":"voters", "json": True}
resp = requests.post("http://eosbattles.com/v1/chain/get_table_rows", json=data)
data = resp.json()
- Then I add the
upper_boundcondition like this, and it not work:
data = {"scope":"eosio", "code":"eosio", "table":"voters", "upper_bound": -1, "json": True}
- Then i also add a
lower_boundcondition like this, and it not work:
data = {"scope":"eosio", "code":"eosio", "table":"voters", "upper_bound": -1, "lower_bound": 10000000, "json": True}
- Then i also add a
limitcondition like this, and it not work:
data = {"scope":"eosio", "code":"eosio", "table":"voters", "upper_bound": -1, "lower_bound": 10000000, "json": True, "limit": 10000000}
Supporting Material/References:
- https://eosio.github.io/eos/group__eosiorpc.html#v1chaingettablerows
Impact
this is my all scripts:
import requests
def test():
more = True
lens = -1
while more:
data = {"scope":"eosio", "code":"eosio", "table":"voters", "json": True}
resp = requests.post("http://eosbattles.com/v1/chain/get_table_rows", json=data)
data = resp.json()
rows = data.get("rows")
print(len(rows))
if __name__ == '__main__':
test()
This feature is not very user-friendly. Since the get_table_rows is generic and works for all tables providing the key upper and lower bounds can be tricky. In the case of the voters table the key is owner which is an account_name but the get_table_rows needs the upper/lower bounds provided in uint64_t. So you much convert your account names to uint64_t to provide to get_table_rows.
Here is an example C++ program that will do that conversion for you: https://onlinegdb.com/ByJR8GOe7
Input name:kevinh
Hello kevinh: 9418972629995356160
This can then be used with cleos:
09:33:25@heifnerk:~/ext/eosio/programs/cleos$ ./cleos get table eosio eosio voters -L 9418972629995356160 -U 9418972629995356161
{
"rows": [{
"owner": "kevinh",
"proxy": "",
"producers": [
"andrianto",
"cjlederer",
"dhanesh",
"jgiszczak",
"kevinh",
"rhagan.test",
"thezealot"
],
"staked": "300000000000",
"last_vote_weight": "108292429672161040.00000000000000000",
"proxied_vote_weight": "0.00000000000000000",
"is_proxy": 0,
"deferred_trx_id": 0,
"last_unstake_time": "1970-01-01T00:00:00",
"unstaking": "0.0000 SYS"
}
],
"more": false
}
Related to #1874. The same change for scope could be done for lower/upper bound.