Revert "Reimplement json_handler::accounts_receivable in terms of receivable iterators."

This reverts commit b08d6ff522.

# Conflicts:
#	nano/node/json_handler.cpp
This commit is contained in:
Colin LeMahieu 2024-08-21 16:54:43 +01:00
commit 52033c759f
No known key found for this signature in database
GPG key ID: 43708520C8DFB938

View file

@ -1054,34 +1054,35 @@ void nano::json_handler::accounts_receivable ()
if (!ec) if (!ec)
{ {
boost::property_tree::ptree peers_l; boost::property_tree::ptree peers_l;
for (auto current = node.ledger.any.receivable_upper_bound (transaction, account, 0), end = node.ledger.any.receivable_end (); current != end && peers_l.size () < count; ++current) for (auto i (node.store.pending.begin (transaction, nano::pending_key (account, 0))), n (node.store.pending.end ()); i != n && nano::pending_key (i->first).account == account && peers_l.size () < count; ++i)
{ {
auto const & [key, info] = *current; nano::pending_key const & key (i->first);
if (include_only_confirmed && !node.ledger.confirmed.block_exists_or_pruned (transaction, key.hash)) if (block_confirmed (node, transaction, key.hash, include_active, include_only_confirmed))
{ {
continue; if (simple)
} {
if (simple) boost::property_tree::ptree entry;
{ entry.put ("", key.hash.to_string ());
boost::property_tree::ptree entry; peers_l.push_back (std::make_pair ("", entry));
entry.put ("", key.hash.to_string ()); }
peers_l.push_back (std::make_pair ("", entry)); else
continue; {
} nano::pending_info const & info (i->second);
if (info.amount.number () < threshold.number ()) if (info.amount.number () >= threshold.number ())
{ {
continue; if (source)
} {
if (source) boost::property_tree::ptree pending_tree;
{ pending_tree.put ("amount", info.amount.number ().convert_to<std::string> ());
boost::property_tree::ptree pending_tree; pending_tree.put ("source", info.source.to_account ());
pending_tree.put ("amount", info.amount.number ().template convert_to<std::string> ()); peers_l.add_child (key.hash.to_string (), pending_tree);
pending_tree.put ("source", info.source.to_account ()); }
peers_l.add_child (key.hash.to_string (), pending_tree); else
} {
else peers_l.put (key.hash.to_string (), info.amount.number ().convert_to<std::string> ());
{ }
peers_l.put (key.hash.to_string (), info.amount.number ().template convert_to<std::string> ()); }
}
} }
} }
if (sorting && !simple) if (sorting && !simple)