Skip to content

Commit bd440cf

Browse files
committed
Refactor code about object_id and object_id_type
And fix some other code smells.
1 parent e37fa14 commit bd440cf

File tree

117 files changed

+2271
-2241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2271
-2241
lines changed

libraries/app/api.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ namespace graphene { namespace app {
382382
FC_ASSERT(_app.chain_database());
383383
const auto& db = *_app.chain_database();
384384
database_api_helper db_api_helper( _app );
385-
asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->id;
386-
asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->id;
385+
asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->get_id();
386+
asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->get_id();
387387
if( a > b ) std::swap(a,b);
388388
const auto& history_idx = db.get_index_type<graphene::market_history::history_index>().indices().get<by_key>();
389389
history_key hkey;
@@ -426,7 +426,7 @@ namespace graphene { namespace app {
426426
account_id_type account;
427427
try {
428428
database_api_helper db_api_helper( _app );
429-
account = db_api_helper.get_account_from_string(account_id_or_name)->id;
429+
account = db_api_helper.get_account_from_string(account_id_or_name)->get_id();
430430
} catch(...) { return result; }
431431

432432
if(_app.is_plugin_enabled("elasticsearch")) {
@@ -479,8 +479,8 @@ namespace graphene { namespace app {
479479
account_id_type account;
480480
try {
481481
database_api_helper db_api_helper( _app );
482-
account = db_api_helper.get_account_from_string(account_name_or_id)->id;
483-
} catch(...) { return result; }
482+
account = db_api_helper.get_account_from_string(account_name_or_id)->get_id();
483+
} catch( const fc::exception& ) { return result; }
484484

485485
fc::time_point_sec start = ostart.valid() ? *ostart : fc::time_point_sec::maximum();
486486

@@ -490,7 +490,7 @@ namespace graphene { namespace app {
490490
return result;
491491

492492
const auto& acc_hist_idx = db.get_index_type<account_history_index>().indices().get<by_op>();
493-
auto itr = acc_hist_idx.lower_bound( boost::make_tuple( account, op_hist_itr->id ) );
493+
auto itr = acc_hist_idx.lower_bound( boost::make_tuple( account, op_hist_itr->get_id() ) );
494494
auto itr_end = acc_hist_idx.upper_bound( account );
495495

496496
while( itr != itr_end && result.size() < limit )
@@ -521,7 +521,7 @@ namespace graphene { namespace app {
521521
account_id_type account;
522522
try {
523523
database_api_helper db_api_helper( _app );
524-
account = db_api_helper.get_account_from_string(account_id_or_name)->id;
524+
account = db_api_helper.get_account_from_string(account_id_or_name)->get_id();
525525
} catch(...) { return result; }
526526
const auto& stats = account(db).statistics(db);
527527
if( stats.most_recent_op == account_history_id_type() ) return result;
@@ -541,7 +541,7 @@ namespace graphene { namespace app {
541541
else node = &node->next(db);
542542
}
543543
if( stop.instance.value == 0 && result.size() < limit ) {
544-
auto head = db.find(account_history_id_type());
544+
const auto* head = db.find(account_history_id_type());
545545
if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_type)
546546
result.push_back(head->operation_id(db));
547547
}
@@ -566,7 +566,7 @@ namespace graphene { namespace app {
566566
account_id_type account;
567567
try {
568568
database_api_helper db_api_helper( _app );
569-
account = db_api_helper.get_account_from_string(account_id_or_name)->id;
569+
account = db_api_helper.get_account_from_string(account_id_or_name)->get_id();
570570
} catch(...) { return result; }
571571
const auto& stats = account(db).statistics(db);
572572
if( start == 0 )
@@ -674,8 +674,8 @@ namespace graphene { namespace app {
674674

675675
const auto& db = *_app.chain_database();
676676
database_api_helper db_api_helper( _app );
677-
asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->id;
678-
asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->id;
677+
asset_id_type a = db_api_helper.get_asset_from_string( asset_a )->get_id();
678+
asset_id_type b = db_api_helper.get_asset_from_string( asset_b )->get_id();
679679
vector<bucket_object> result;
680680
const auto configured_limit = _app.get_options().api_limit_get_market_history;
681681
result.reserve( configured_limit );
@@ -899,7 +899,7 @@ namespace graphene { namespace app {
899899
("configured_limit", configured_limit) );
900900

901901
database_api_helper db_api_helper( _app );
902-
asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->id;
902+
asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->get_id();
903903
const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
904904
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
905905

@@ -933,7 +933,7 @@ namespace graphene { namespace app {
933933
int64_t asset_api::get_asset_holders_count( const std::string& asset_symbol_or_id ) const {
934934
const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >();
935935
database_api_helper db_api_helper( _app );
936-
asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->id;
936+
asset_id_type asset_id = db_api_helper.get_asset_from_string( asset_symbol_or_id )->get_id();
937937
auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) );
938938

939939
int64_t count = boost::distance(range) - 1;
@@ -996,8 +996,8 @@ namespace graphene { namespace app {
996996
vector< limit_order_group > result;
997997

998998
database_api_helper db_api_helper( _app );
999-
asset_id_type base_asset_id = db_api_helper.get_asset_from_string( base_asset )->id;
1000-
asset_id_type quote_asset_id = db_api_helper.get_asset_from_string( quote_asset )->id;
999+
asset_id_type base_asset_id = db_api_helper.get_asset_from_string( base_asset )->get_id();
1000+
asset_id_type quote_asset_id = db_api_helper.get_asset_from_string( quote_asset )->get_id();
10011001

10021002
price max_price = price::max( base_asset_id, quote_asset_id );
10031003
price min_price = price::min( base_asset_id, quote_asset_id );
@@ -1037,7 +1037,7 @@ namespace graphene { namespace app {
10371037
if( o_account_name_or_id.valid() )
10381038
{
10391039
const string& account_name_or_id = *o_account_name_or_id;
1040-
const account_id_type account_id = db_api_helper.get_account_from_string(account_name_or_id)->id;
1040+
const account_id_type account_id = db_api_helper.get_account_from_string(account_name_or_id)->get_id();
10411041
if( catalog.valid() )
10421042
{
10431043
if( key.valid() )

0 commit comments

Comments
 (0)