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 7cae7fb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,17 +956,26 @@ 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 ());
}
else
{
frontiers.put (account.to_account (), "");
}
}
else
{
frontiers.put (account_from_request.second.data (), boost::str (boost::format ("error: %1%") % ec.message ()));
ec = {};
}
}
response_l.add_child ("frontiers", frontiers);
Expand Down

0 comments on commit 7cae7fb

Please sign in to comment.