peerplays-network / peerplays

The Peerplays Blockchain
https://www.peerplays.com
MIT License
34 stars 18 forks source link

Remove duplicated code #7

Open oxarbitrage opened 5 years ago

oxarbitrage commented 5 years ago

The get_relevant_accounts function is duplicated, present in api.cpp and in db_notify.cpp.

The one in db_notify produces some warnings of types not being handled in switch statements:

/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp: In function ‘void get_relevant_accounts(const graphene::db::object*, boost::container::flat_set<graphene::db::object_id<1u, 2u, graphene::chain::account_object> >&)’:
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘tournament_object_type’ not handled in switch [-Wswitch]
       switch( (object_type)obj->id.type() )
             ^
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘tournament_details_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘match_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘game_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘sport_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘event_group_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘event_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘betting_market_rules_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘betting_market_group_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘betting_market_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:290:13: warning: enumeration value ‘bet_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:365:13: warning: enumeration value ‘impl_asset_dividend_data_type’ not handled in switch [-Wswitch]
       switch( (impl_object_type)obj->id.type() )
             ^
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:365:13: warning: enumeration value ‘impl_pending_dividend_payout_balance_for_holder_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:365:13: warning: enumeration value ‘impl_distributed_dividend_balance_data_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:365:13: warning: enumeration value ‘impl_betting_market_position_object_type’ not handled in switch [-Wswitch]
/home/alfredo/CLionProjects/gpos/libraries/chain/db_notify.cpp:365:13: warning: enumeration value ‘impl_global_betting_statistics_object_type’ not handled in switch [-Wswitch]

Either we:

xeroc commented 5 years ago

I prefer the second option :D