Implement ledger::account_receivable in terms of receivable iterators
This commit is contained in:
parent
994bef05d4
commit
a5e1500680
1 changed files with 4 additions and 12 deletions
|
|
@ -855,19 +855,11 @@ nano::uint128_t nano::ledger::account_balance (store::transaction const & transa
|
|||
|
||||
nano::uint128_t nano::ledger::account_receivable (store::transaction const & transaction_a, nano::account const & account_a, bool only_confirmed_a)
|
||||
{
|
||||
nano::uint128_t result (0);
|
||||
nano::account end (account_a.number () + 1);
|
||||
for (auto i (store.pending.begin (transaction_a, nano::pending_key (account_a, 0))), n (store.pending.begin (transaction_a, nano::pending_key (end, 0))); i != n; ++i)
|
||||
nano::uint128_t result{ 0 };
|
||||
for (auto i = receivable_upper_bound (transaction_a, account_a, 0), n = receivable_end (); i != n; ++i)
|
||||
{
|
||||
nano::pending_info const & info (i->second);
|
||||
if (only_confirmed_a)
|
||||
{
|
||||
if (block_confirmed (transaction_a, i->first.hash))
|
||||
{
|
||||
result += info.amount.number ();
|
||||
}
|
||||
}
|
||||
else
|
||||
auto const & [key, info] = *i;
|
||||
if (!only_confirmed_a || block_confirmed (transaction_a, key.hash))
|
||||
{
|
||||
result += info.amount.number ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue