Revert "Rewrite json_handler::unopened in terms of receivable iterators"
This reverts commit d58316451a.
# Conflicts:
# nano/node/json_handler.cpp
This commit is contained in:
parent
2ba14ed395
commit
ea79e5bd14
1 changed files with 38 additions and 18 deletions
|
|
@ -4279,8 +4279,8 @@ void nano::json_handler::unchecked_keys ()
|
||||||
|
|
||||||
void nano::json_handler::unopened ()
|
void nano::json_handler::unopened ()
|
||||||
{
|
{
|
||||||
auto count (count_optional_impl ());
|
auto count{ count_optional_impl () };
|
||||||
auto threshold (threshold_optional_impl ());
|
auto threshold{ threshold_optional_impl () };
|
||||||
nano::account start{ 1 }; // exclude burn account by default
|
nano::account start{ 1 }; // exclude burn account by default
|
||||||
boost::optional<std::string> account_text (request.get_optional<std::string> ("account"));
|
boost::optional<std::string> account_text (request.get_optional<std::string> ("account"));
|
||||||
if (account_text.is_initialized ())
|
if (account_text.is_initialized ())
|
||||||
|
|
@ -4289,28 +4289,48 @@ void nano::json_handler::unopened ()
|
||||||
}
|
}
|
||||||
if (!ec)
|
if (!ec)
|
||||||
{
|
{
|
||||||
auto transaction = node.ledger.tx_begin_read ();
|
auto transaction = node.store.tx_begin_read ();
|
||||||
auto & ledger = node.ledger;
|
auto iterator = node.store.pending.begin (transaction, nano::pending_key (start, 0));
|
||||||
boost::property_tree::ptree accounts;
|
auto end = node.store.pending.end ();
|
||||||
for (auto iterator = ledger.any.receivable_upper_bound (transaction, start, 0), end = ledger.any.receivable_end (); iterator != end && accounts.size () < count;)
|
nano::account current_account = start;
|
||||||
{
|
|
||||||
auto const & [key, info] = *iterator;
|
|
||||||
nano::account account = key.account;
|
|
||||||
if (!node.store.account.exists (transaction, account))
|
|
||||||
{
|
|
||||||
nano::uint128_t current_account_sum{ 0 };
|
nano::uint128_t current_account_sum{ 0 };
|
||||||
while (iterator != end)
|
boost::property_tree::ptree accounts;
|
||||||
|
while (iterator != end && accounts.size () < count)
|
||||||
{
|
{
|
||||||
auto const & [key, info] = *iterator;
|
nano::pending_key key{ iterator->first };
|
||||||
|
nano::account account{ key.account };
|
||||||
|
nano::pending_info info{ iterator->second };
|
||||||
|
if (node.store.account.exists (transaction, account))
|
||||||
|
{
|
||||||
|
if (account.number () == std::numeric_limits<nano::uint256_t>::max ())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Skip existing accounts
|
||||||
|
iterator = node.store.pending.begin (transaction, nano::pending_key (account.number () + 1, 0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (account != current_account)
|
||||||
|
{
|
||||||
|
if (current_account_sum > 0)
|
||||||
|
{
|
||||||
|
if (current_account_sum >= threshold.number ())
|
||||||
|
{
|
||||||
|
accounts.put (current_account.to_account (), current_account_sum.convert_to<std::string> ());
|
||||||
|
}
|
||||||
|
current_account_sum = 0;
|
||||||
|
}
|
||||||
|
current_account = account;
|
||||||
|
}
|
||||||
current_account_sum += info.amount.number ();
|
current_account_sum += info.amount.number ();
|
||||||
++iterator;
|
++iterator;
|
||||||
}
|
}
|
||||||
if (current_account_sum >= threshold.number ())
|
}
|
||||||
|
// last one after iterator reaches end
|
||||||
|
if (accounts.size () < count && current_account_sum > 0 && current_account_sum >= threshold.number ())
|
||||||
{
|
{
|
||||||
accounts.put (account.to_account (), current_account_sum.convert_to<std::string> ());
|
accounts.put (current_account.to_account (), current_account_sum.convert_to<std::string> ());
|
||||||
}
|
|
||||||
}
|
|
||||||
iterator = ledger.any.receivable_upper_bound (transaction, account);
|
|
||||||
}
|
}
|
||||||
response_l.add_child ("accounts", accounts);
|
response_l.add_child ("accounts", accounts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue