Skip to content

Commit

Permalink
Changes the accounts_frontiers RPC to return per account results
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Silva committed Apr 13, 2022
1 parent cf5a088 commit c4ca179
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,18 +956,25 @@ void nano::json_handler::accounts_create ()
void nano::json_handler::accounts_frontiers ()
{
boost::property_tree::ptree frontiers;
auto transaction (node.store.tx_begin_read ());
for (auto & accounts : request.get_child ("accounts"))
auto transaction = node.store.tx_begin_read ();
for (auto & account_from_request : request.get_child ("accounts"))
{
auto account (account_impl (accounts.second.data ()));
auto account = account_impl (account_from_request.second.data ());
if (!ec)
{
auto latest (node.ledger.latest (transaction, account));
auto latest = node.ledger.latest (transaction, account);
if (!latest.is_zero ())
{
frontiers.put (account.to_account (), latest.to_string ());
continue;
}
else
{
ec = nano::error_common::account_not_found;
}
}
frontiers.put (account_from_request.second.data (), boost::str (boost::format ("error: %1%") % ec.message ()));
ec = {};
}
response_l.add_child ("frontiers", frontiers);
response_errors ();
Expand Down

0 comments on commit c4ca179

Please sign in to comment.