diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 0cb6ae0d..53dbb06d 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -555,18 +555,28 @@ namespace graphene { namespace app { FC_ASSERT( limit <= 100 ); vector result; const auto& stats = account(db).statistics(db); - if( stats.most_recent_op == account_transaction_history_id_type() ) return result; - const account_transaction_history_object* node = &stats.most_recent_op(db); - if( start == operation_history_id_type() ) - start = node->operation_id; - - while(node && node->operation_id.instance.value > stop.instance.value && result.size() < limit) + const account_transaction_history_object* node = nullptr; + if( stats.most_recent_op != account_transaction_history_id_type() ) { - if( node->operation_id.instance.value <= start.instance.value ) + node = &stats.most_recent_op(db); + if( start == operation_history_id_type() ) + start = node->operation_id; + + while(node && node->operation_id.instance.value > stop.instance.value && result.size() < limit) + { + if( node->operation_id.instance.value <= start.instance.value ) + result.push_back( node->operation_id(db) ); + if( node->next == account_transaction_history_id_type() ) + node = nullptr; + else node = &node->next(db); + } + } + + if( stop.instance.value == 0 && result.size() < limit ) + { + node = db.find(account_transaction_history_id_type()); + if( node && node->operation_id.instance.value == account.instance.value) result.push_back( node->operation_id(db) ); - if( node->next == account_transaction_history_id_type() ) - node = nullptr; - else node = &node->next(db); } return result;