@@ -308,7 +308,7 @@ namespace graphene { namespace app {
308
308
return result;
309
309
}
310
310
311
- vector<operation_history_object> history_api::get_account_history ( account_id_type account ,
311
+ vector<operation_history_object> history_api::get_account_history ( const std::string account_id_or_name ,
312
312
operation_history_id_type stop,
313
313
unsigned limit,
314
314
operation_history_id_type start ) const
@@ -317,7 +317,9 @@ namespace graphene { namespace app {
317
317
const auto & db = *_app.chain_database ();
318
318
FC_ASSERT ( limit <= 100 );
319
319
vector<operation_history_object> result;
320
+ account_id_type account;
320
321
try {
322
+ account = database_api.get_account_id_from_string (account_id_or_name);
321
323
const account_transaction_history_object& node = account (db).statistics (db).most_recent_op (db);
322
324
if (start == operation_history_id_type () || start.instance .value > node.operation_id .instance .value )
323
325
start = node.operation_id ;
@@ -341,7 +343,7 @@ namespace graphene { namespace app {
341
343
return result;
342
344
}
343
345
344
- vector<operation_history_object> history_api::get_account_history_operations ( account_id_type account ,
346
+ vector<operation_history_object> history_api::get_account_history_operations ( const std::string account_id_or_name ,
345
347
int operation_id,
346
348
operation_history_id_type start,
347
349
operation_history_id_type stop,
@@ -351,6 +353,10 @@ namespace graphene { namespace app {
351
353
const auto & db = *_app.chain_database ();
352
354
FC_ASSERT ( limit <= 100 );
353
355
vector<operation_history_object> result;
356
+ account_id_type account;
357
+ try {
358
+ account = database_api.get_account_id_from_string (account_id_or_name);
359
+ } catch (...) { return result; }
354
360
const auto & stats = account (db).statistics (db);
355
361
if ( stats.most_recent_op == account_transaction_history_id_type () ) return result;
356
362
const account_transaction_history_object* node = &stats.most_recent_op (db);
@@ -377,7 +383,7 @@ namespace graphene { namespace app {
377
383
}
378
384
379
385
380
- vector<operation_history_object> history_api::get_relative_account_history ( account_id_type account ,
386
+ vector<operation_history_object> history_api::get_relative_account_history ( const std::string account_id_or_name ,
381
387
uint32_t stop,
382
388
unsigned limit,
383
389
uint32_t start) const
@@ -386,13 +392,16 @@ namespace graphene { namespace app {
386
392
const auto & db = *_app.chain_database ();
387
393
FC_ASSERT (limit <= 100 );
388
394
vector<operation_history_object> result;
395
+ account_id_type account;
396
+ try {
397
+ account = database_api.get_account_id_from_string (account_id_or_name);
398
+ } catch (...) { return result; }
389
399
const auto & stats = account (db).statistics (db);
390
400
if ( start == 0 )
391
401
start = stats.total_ops ;
392
402
else
393
403
start = min ( stats.total_ops , start );
394
404
395
-
396
405
if ( start >= stop && start > stats.removed_ops && limit > 0 )
397
406
{
398
407
const auto & hist_idx = db.get_index_type <account_transaction_history_index>();
@@ -418,12 +427,12 @@ namespace graphene { namespace app {
418
427
return hist->tracked_buckets ();
419
428
}
420
429
421
- history_operation_detail history_api::get_account_history_by_operations (account_id_type account , vector<uint16_t > operation_types, uint32_t start, unsigned limit)
430
+ history_operation_detail history_api::get_account_history_by_operations (const std::string account_id_or_name , vector<uint16_t > operation_types, uint32_t start, unsigned limit)
422
431
{
423
- FC_ASSERT (limit <= 100 );
424
- history_operation_detail result;
425
- vector<operation_history_object> objs = get_relative_account_history (account , start, limit, limit + start - 1 );
426
- std::for_each (objs.begin (), objs.end (), [&](const operation_history_object &o) {
432
+ FC_ASSERT (limit <= 100 );
433
+ history_operation_detail result;
434
+ vector<operation_history_object> objs = get_relative_account_history (account_id_or_name , start, limit, limit + start - 1 );
435
+ std::for_each (objs.begin (), objs.end (), [&](const operation_history_object &o) {
427
436
if (operation_types.empty () || find (operation_types.begin (), operation_types.end (), o.op .which ()) != operation_types.end ()) {
428
437
result.operation_history_objs .push_back (o);
429
438
}
0 commit comments