Reimplement json_handler::wallet_receivable in terms of receivable iterators
This commit is contained in:
parent
9d962e6e46
commit
873760f345
1 changed files with 30 additions and 31 deletions
|
|
@ -4788,31 +4788,33 @@ void nano::json_handler::wallet_receivable ()
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree pending;
|
boost::property_tree::ptree pending;
|
||||||
auto transaction (node.wallets.tx_begin_read ());
|
auto transaction (node.wallets.tx_begin_read ());
|
||||||
auto block_transaction (node.store.tx_begin_read ());
|
auto block_transaction = node.store.tx_begin_read ();
|
||||||
for (auto i (wallet->store.begin (transaction)), n (wallet->store.end ()); i != n; ++i)
|
for (auto i (wallet->store.begin (transaction)), n (wallet->store.end ()); i != n; ++i)
|
||||||
{
|
{
|
||||||
nano::account const & account (i->first);
|
nano::account const & account (i->first);
|
||||||
boost::property_tree::ptree peers_l;
|
boost::property_tree::ptree peers_l;
|
||||||
for (auto ii (node.store.pending.begin (block_transaction, nano::pending_key (account, 0))), nn (node.store.pending.end ()); ii != nn && nano::pending_key (ii->first).account == account && peers_l.size () < count; ++ii)
|
for (auto current = node.ledger.receivable_upper_bound (block_transaction, account, 0), end = node.ledger.receivable_end (); current != end && (peers_l.size () < count); ++current)
|
||||||
{
|
{
|
||||||
nano::pending_key key (ii->first);
|
auto const & [key, info] = *current;
|
||||||
if (block_confirmed (node, block_transaction, key.hash, include_active, include_only_confirmed))
|
if (include_only_confirmed && !node.ledger.block_confirmed (block_transaction, key.hash))
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (threshold.is_zero () && !source)
|
if (threshold.is_zero () && !source)
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree entry;
|
boost::property_tree::ptree entry;
|
||||||
entry.put ("", key.hash.to_string ());
|
entry.put ("", key.hash.to_string ());
|
||||||
peers_l.push_back (std::make_pair ("", entry));
|
peers_l.push_back (std::make_pair ("", entry));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
if (info.amount.number () < threshold.number ())
|
||||||
{
|
|
||||||
nano::pending_info info (ii->second);
|
|
||||||
if (info.amount.number () >= threshold.number ())
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (source || min_version)
|
if (source || min_version)
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree pending_tree;
|
boost::property_tree::ptree pending_tree;
|
||||||
pending_tree.put ("amount", info.amount.number ().convert_to<std::string> ());
|
pending_tree.put ("amount", info.amount.number ().template convert_to<std::string> ());
|
||||||
if (source)
|
if (source)
|
||||||
{
|
{
|
||||||
pending_tree.put ("source", info.source.to_account ());
|
pending_tree.put ("source", info.source.to_account ());
|
||||||
|
|
@ -4825,10 +4827,7 @@ void nano::json_handler::wallet_receivable ()
|
||||||
}
|
}
|
||||||
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 (!peers_l.empty ())
|
if (!peers_l.empty ())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue