Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

support reverse iteration & show RAM payer in get table (#6216 #6271) #6264

Merged
merged 5 commits into from
Nov 19, 2018

Conversation

taokayan
Copy link
Contributor

@taokayan taokayan commented Nov 7, 2018

#6216 #6271

Change Description

  • allow developers/users to reversely iterate rows in get_table_rows RPC call
  • allow developers/users to get RAM payer information for each row
  • allow developers/users to reversely iterate rows in get_table_by_scope RPC call

API Changes
RPC call: get_table_rows (cleos get table)
RPC call: get_table_by_scope (cleos get scope)

Documentation Additions
new parameters for get table rows:
-r,--reverse Iterate in reverse order (default: false)
--show-payer show RAM payer (default: false)

new parameter for get table by scope:
-r,--reverse Iterate in reverse order (default: false)

Command example
find the bid name with the lowest bid:

./cleos get table eosio eosio namebids --key-type i64 --index 2 -r -l 1
{
  "rows": [{
      "newname": "com",
      "high_bidder": "a123",
      "high_bid": 100000,
      "last_bid_time": "1541667021500000"
    }
  ],
  "more": true
}

to show all bid names from lowbid to highbid, with RAM payer information

./cleos get table eosio eosio namebids --key-type i64 --index 2 -r --show-payer
{
  "rows": [{
      "data": {
        "newname": "com",
        "high_bidder": "a123",
        "high_bid": 100000,
        "last_bid_time": "1541667021500000"
      },
      "payer": "a123"
    },{
      "data": {
        "newname": "abc",
        "high_bidder": "a123",
        "high_bid": 110000,
        "last_bid_time": "1541667021500000"
      },
      "payer": "a123"
    },{
      "data": {
        "newname": "ddd",
        "high_bidder": "a123",
        "high_bid": 120000,
        "last_bid_time": "1541667021500000"
      },
      "payer": "a123"
    },{
      "data": {
        "newname": "zoo",
        "high_bidder": "a123",
        "high_bid": 9990000,
        "last_bid_time": "1541667022000000"
      },
      "payer": "a123"
    }
  ],
  "more": false
}

Copy link
Contributor

@heifner heifner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests to tests/get_table_tests.cpp for this new functionality.

@@ -269,6 +269,7 @@ class read_only {
string key_type; // type of key specified by index_position
string index_position; // 1 - primary (first), 2 - secondary index (in order defined by multi_index), 3 - third index, etc
string encode_type{"dec"}; //dec, hex , default=dec
bool reverse = false; // from upper to lower
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be optional to support older clients.

@taokayan taokayan changed the title support reverse iteration in get table (#6216) support reverse iteration & show RAM payer in get table (#6216) Nov 8, 2018
@taokayan taokayan changed the title support reverse iteration & show RAM payer in get table (#6216) support reverse iteration & show RAM payer in get table (#6216 #6271) Nov 8, 2018
@arhag arhag changed the base branch from develop to develop-2 November 9, 2018 23:47
@arhag arhag changed the base branch from develop-2 to develop November 9, 2018 23:48
@arhag
Copy link
Contributor

arhag commented Nov 10, 2018

I pushed some changes to account for the changed definition of upper_bound from PR #6285. I also added support for reverse iteration in get_table_by_scope.

@znebby
Copy link

znebby commented Nov 19, 2018

Hey guys, I'm really looking forward to getting this merged in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants