Skip to content

Commit

Permalink
Add "count" and "offset" parameters to "delegators" RPC (nanocurrency…
Browse files Browse the repository at this point in the history
  • Loading branch information
shryder committed Jun 12, 2021
1 parent 6ee8673 commit d42b097
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2069,15 +2069,29 @@ void nano::json_handler::database_txn_tracker ()
void nano::json_handler::delegators ()
{
auto account (account_impl ());
auto count (count_optional_impl ());
auto offset (offset_optional_impl (0));

if (!ec)
{
boost::property_tree::ptree delegators;
auto transaction (node.store.tx_begin_read ());
uint64_t delegators_count = 0;

for (auto i (node.store.account.begin (transaction)), n (node.store.account.end ()); i != n; ++i)
{
nano::account_info const & info (i->second);
if (info.representative == account)
{
if (delegators.size () >= count)
{
break;
}
++delegators_count;
if (offset > 0 && delegators_count <= offset)
{
continue;
}
std::string balance;
nano::uint128_union (info.balance).encode_dec (balance);
nano::account const & account (i->first);
Expand Down

0 comments on commit d42b097

Please sign in to comment.