Skip to content

Commit

Permalink
Merge pull request steemit#2343 from steemit/2337-get-account-history…
Browse files Browse the repository at this point in the history
…-loop-2-master

Fix iteration in account_history_api.cpp steemit#2337 (master branch)
  • Loading branch information
Michael Vandeberg authored Apr 17, 2018
2 parents db93b69 + 7bda288 commit 4a189dc
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ DEFINE_API_IMPL( account_history_api_impl, get_account_history )

const auto& idx = _db.get_index< chain::account_history_index, chain::by_account >();
auto itr = idx.lower_bound( boost::make_tuple( args.account, args.start ) );
auto end = idx.upper_bound( boost::make_tuple( args.account, std::max( int64_t(0), int64_t(itr->sequence) - args.limit ) ) );
uint32_t n = 0;

get_account_history_return result;
while( itr != end )
while( true )
{
if( itr == idx.end() )
break;
if( itr->account != args.account )
break;
if( n >= args.limit )
break;
result.history[ itr->sequence ] = _db.get( itr->op );
++itr;
++n;
}

return result;
Expand Down

0 comments on commit 4a189dc

Please sign in to comment.