From 52033c759f79cdb7a2f7c88bf20ae5a54812e22e Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Wed, 21 Aug 2024 16:54:43 +0100 Subject: [PATCH] Revert "Reimplement json_handler::accounts_receivable in terms of receivable iterators." This reverts commit b08d6ff5228f71abed7785fdab187a6e8a5525cc. # Conflicts: # nano/node/json_handler.cpp --- nano/node/json_handler.cpp | 53 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index a75c63a4d..e5f87a7c4 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -1054,34 +1054,35 @@ void nano::json_handler::accounts_receivable () if (!ec) { 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; - if (include_only_confirmed && !node.ledger.confirmed.block_exists_or_pruned (transaction, key.hash)) + nano::pending_key const & key (i->first); + if (block_confirmed (node, transaction, key.hash, include_active, include_only_confirmed)) { - continue; - } - if (simple) - { - boost::property_tree::ptree entry; - entry.put ("", key.hash.to_string ()); - peers_l.push_back (std::make_pair ("", entry)); - continue; - } - if (info.amount.number () < threshold.number ()) - { - continue; - } - if (source) - { - boost::property_tree::ptree pending_tree; - pending_tree.put ("amount", info.amount.number ().template convert_to ()); - pending_tree.put ("source", info.source.to_account ()); - peers_l.add_child (key.hash.to_string (), pending_tree); - } - else - { - peers_l.put (key.hash.to_string (), info.amount.number ().template convert_to ()); + if (simple) + { + boost::property_tree::ptree entry; + entry.put ("", key.hash.to_string ()); + peers_l.push_back (std::make_pair ("", entry)); + } + else + { + nano::pending_info const & info (i->second); + if (info.amount.number () >= threshold.number ()) + { + if (source) + { + boost::property_tree::ptree pending_tree; + pending_tree.put ("amount", info.amount.number ().convert_to ()); + pending_tree.put ("source", info.source.to_account ()); + peers_l.add_child (key.hash.to_string (), pending_tree); + } + else + { + peers_l.put (key.hash.to_string (), info.amount.number ().convert_to ()); + } + } + } } } if (sorting && !simple)