Optimize "*_pending" RPC calls when include_active used (#1277)

This commit is contained in:
SergiySW 2018-10-09 18:41:25 +03:00 committed by Roy Keene
commit 61eb38241d

View file

@ -773,8 +773,7 @@ void rai::rpc_handler::accounts_pending ()
for (auto i (node.store.pending_begin (transaction, rai::pending_key (account, 0))), n (node.store.pending_begin (transaction, rai::pending_key (end, 0))); i != n && peers_l.size () < count; ++i)
{
rai::pending_key key (i->first);
std::shared_ptr<rai::block> block (node.store.block_get (transaction, key.hash));
assert (block);
std::shared_ptr<rai::block> block (include_active ? nullptr : node.store.block_get (transaction, key.hash));
if (include_active || (block && !node.active.active (*block)))
{
if (threshold.is_zero () && !source)
@ -2073,8 +2072,7 @@ void rai::rpc_handler::pending ()
for (auto i (node.store.pending_begin (transaction, rai::pending_key (account, 0))), n (node.store.pending_begin (transaction, rai::pending_key (end, 0))); i != n && peers_l.size () < count; ++i)
{
rai::pending_key key (i->first);
std::shared_ptr<rai::block> block (node.store.block_get (transaction, key.hash));
assert (block);
std::shared_ptr<rai::block> block (include_active ? nullptr : node.store.block_get (transaction, key.hash));
if (include_active || (block && !node.active.active (*block)))
{
if (threshold.is_zero () && !source && !min_version)
@ -3262,8 +3260,7 @@ void rai::rpc_handler::wallet_pending ()
for (auto ii (node.store.pending_begin (transaction, rai::pending_key (account, 0))), nn (node.store.pending_begin (transaction, rai::pending_key (end, 0))); ii != nn && peers_l.size () < count; ++ii)
{
rai::pending_key key (ii->first);
std::shared_ptr<rai::block> block (node.store.block_get (transaction, key.hash));
assert (block);
std::shared_ptr<rai::block> block (include_active ? nullptr : node.store.block_get (transaction, key.hash));
if (include_active || (block && !node.active.active (*block)))
{
if (threshold.is_zero () && !source)