Skip to content

Commit

Permalink
Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Apr 7, 2021
1 parent aac5f43 commit 52ebad4
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 84 deletions.
12 changes: 7 additions & 5 deletions libraries/plugins/account_history/account_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace detail
class account_history_plugin_impl
{
public:
account_history_plugin_impl(account_history_plugin& _plugin)
explicit account_history_plugin_impl(account_history_plugin& _plugin)
: _self( _plugin )
{ }

Expand All @@ -60,6 +60,9 @@ class account_history_plugin_impl
return _self.database();
}

friend class graphene::account_history::account_history_plugin;

private:
account_history_plugin& _self;
flat_set<account_id_type> _tracked_accounts;
flat_set<account_id_type> _extended_history_accounts;
Expand All @@ -68,7 +71,7 @@ class account_history_plugin_impl
primary_index< operation_history_index >* _oho_index;
uint64_t _max_ops_per_account = -1;
uint64_t _extended_max_ops_per_account = -1;
private:

/** add one history record, then check and remove the earliest history record */
void add_account_history( const account_id_type account_id, const operation_history_id_type op_id );

Expand Down Expand Up @@ -279,11 +282,10 @@ account_history_plugin::account_history_plugin(graphene::app::application& app)
plugin(app),
my( std::make_unique<detail::account_history_plugin_impl>(*this) )
{
// Nothing else to do
}

account_history_plugin::~account_history_plugin()
{
}
account_history_plugin::~account_history_plugin() = default;

std::string account_history_plugin::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace detail
class account_history_plugin : public graphene::app::plugin
{
public:
account_history_plugin(graphene::app::application& app);
explicit account_history_plugin(graphene::app::application& app);
~account_history_plugin() override;

std::string plugin_name()const override;
Expand All @@ -76,7 +76,7 @@ class account_history_plugin : public graphene::app::plugin

flat_set<account_id_type> tracked_accounts()const;

friend class detail::account_history_plugin_impl;
private:
std::unique_ptr<detail::account_history_plugin_impl> my;
};

Expand Down
11 changes: 4 additions & 7 deletions libraries/plugins/api_helper_indexes/api_helper_indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace detail
class api_helper_indexes_impl
{
public:
api_helper_indexes_impl(api_helper_indexes& _plugin)
explicit api_helper_indexes_impl(api_helper_indexes& _plugin)
: _self( _plugin )
{ }

Expand All @@ -142,10 +142,8 @@ class api_helper_indexes_impl
return _self.database();
}

api_helper_indexes& _self;

private:

api_helper_indexes& _self;
};

} // end namespace detail
Expand All @@ -154,11 +152,10 @@ api_helper_indexes::api_helper_indexes(graphene::app::application& app) :
plugin(app),
my( std::make_unique<detail::api_helper_indexes_impl>(*this) )
{
// Nothing else to do
}

api_helper_indexes::~api_helper_indexes()
{
}
api_helper_indexes::~api_helper_indexes() = default;

std::string api_helper_indexes::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace detail
class api_helper_indexes : public graphene::app::plugin
{
public:
api_helper_indexes(graphene::app::application& app);
explicit api_helper_indexes(graphene::app::application& app);
~api_helper_indexes() override;

std::string plugin_name()const override;
Expand Down
19 changes: 6 additions & 13 deletions libraries/plugins/custom_operations/custom_operations_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ namespace detail
class custom_operations_plugin_impl
{
public:
custom_operations_plugin_impl(custom_operations_plugin& _plugin)
explicit custom_operations_plugin_impl(custom_operations_plugin& _plugin)
: _self( _plugin )
{ }
virtual ~custom_operations_plugin_impl();

void onBlock();

Expand All @@ -47,12 +46,12 @@ class custom_operations_plugin_impl
return _self.database();
}

custom_operations_plugin& _self;

uint32_t _start_block = 45000000;
friend class graphene::custom_operations::custom_operations_plugin;

private:
custom_operations_plugin& _self;

uint32_t _start_block = 45000000;
};

struct custom_op_visitor
Expand Down Expand Up @@ -98,22 +97,16 @@ void custom_operations_plugin_impl::onBlock()
}
}

custom_operations_plugin_impl::~custom_operations_plugin_impl()
{
// nothing to do
}

} // end namespace detail

custom_operations_plugin::custom_operations_plugin(graphene::app::application& app) :
plugin(app),
my( std::make_unique<detail::custom_operations_plugin_impl>(*this) )
{
// Nothing to do
}

custom_operations_plugin::~custom_operations_plugin()
{
}
custom_operations_plugin::~custom_operations_plugin() = default;

std::string custom_operations_plugin::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace detail
class custom_operations_plugin : public graphene::app::plugin
{
public:
custom_operations_plugin(graphene::app::application& app);
explicit custom_operations_plugin(graphene::app::application& app);
~custom_operations_plugin() override;

std::string plugin_name()const override;
Expand All @@ -52,7 +52,7 @@ class custom_operations_plugin : public graphene::app::plugin
void plugin_initialize(const boost::program_options::variables_map& options) override;
void plugin_startup() override;

friend class detail::custom_operations_plugin_impl;
private:
std::unique_ptr<detail::custom_operations_plugin_impl> my;
};

Expand Down
13 changes: 7 additions & 6 deletions libraries/plugins/delayed_node/delayed_node_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ struct delayed_node_plugin_impl {
}

delayed_node_plugin::delayed_node_plugin(graphene::app::application& app) :
plugin(app),
my(nullptr)
{}
plugin(app)
{
// Nothing else to do
}

delayed_node_plugin::~delayed_node_plugin()
{}
delayed_node_plugin::~delayed_node_plugin() = default;

void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg)
{
cli.add_options()
("trusted-node", boost::program_options::value<std::string>(), "RPC endpoint of a trusted validating node (required for delayed_node)")
("trusted-node", boost::program_options::value<std::string>(),
"RPC endpoint of a trusted validating node (required for delayed_node)")
;
cfg.add(cli);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class delayed_node_plugin : public graphene::app::plugin
{
std::unique_ptr<detail::delayed_node_plugin_impl> my;
public:
delayed_node_plugin(graphene::app::application& app);
explicit delayed_node_plugin(graphene::app::application& app);
~delayed_node_plugin() override;

std::string plugin_name()const override { return "delayed_node"; }
void plugin_set_program_options(boost::program_options::options_description&,
boost::program_options::options_description& cfg) override;
boost::program_options::options_description& cfg) override;
void plugin_initialize(const boost::program_options::variables_map& options) override;
void plugin_startup() override;
void mainloop();
Expand Down
8 changes: 3 additions & 5 deletions libraries/plugins/elasticsearch/elasticsearch_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace detail
class elasticsearch_plugin_impl
{
public:
elasticsearch_plugin_impl(elasticsearch_plugin& _plugin)
explicit elasticsearch_plugin_impl(elasticsearch_plugin& _plugin)
: _self( _plugin )
{
curl = curl_easy_init();
Expand Down Expand Up @@ -102,7 +102,6 @@ elasticsearch_plugin_impl::~elasticsearch_plugin_impl()
curl_easy_cleanup(curl);
curl = nullptr;
}
return;
}

bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b )
Expand Down Expand Up @@ -437,11 +436,10 @@ elasticsearch_plugin::elasticsearch_plugin(graphene::app::application& app) :
plugin(app),
my( std::make_unique<detail::elasticsearch_plugin_impl>(*this) )
{
// Nothing else to do
}

elasticsearch_plugin::~elasticsearch_plugin()
{
}
elasticsearch_plugin::~elasticsearch_plugin() = default;

std::string elasticsearch_plugin::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum mode { only_save = 0 , only_query = 1, all = 2 };
class elasticsearch_plugin : public graphene::app::plugin
{
public:
elasticsearch_plugin(graphene::app::application& app);
explicit elasticsearch_plugin(graphene::app::application& app);
~elasticsearch_plugin() override;

std::string plugin_name()const override;
Expand Down
8 changes: 3 additions & 5 deletions libraries/plugins/es_objects/es_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace detail
class es_objects_plugin_impl
{
public:
es_objects_plugin_impl(es_objects_plugin& _plugin)
explicit es_objects_plugin_impl(es_objects_plugin& _plugin)
: _self( _plugin )
{
curl = curl_easy_init();
Expand Down Expand Up @@ -269,7 +269,6 @@ es_objects_plugin_impl::~es_objects_plugin_impl()
curl_easy_cleanup(curl);
curl = nullptr;
}
return;
}

} // end namespace detail
Expand All @@ -278,11 +277,10 @@ es_objects_plugin::es_objects_plugin(graphene::app::application& app) :
plugin(app),
my( std::make_unique<detail::es_objects_plugin_impl>(*this) )
{
// Nothing else to do
}

es_objects_plugin::~es_objects_plugin()
{
}
es_objects_plugin::~es_objects_plugin() = default;

std::string es_objects_plugin::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace detail
class es_objects_plugin : public graphene::app::plugin
{
public:
es_objects_plugin(graphene::app::application& app);
~es_objects_plugin();
explicit es_objects_plugin(graphene::app::application& app);
~es_objects_plugin() override;

std::string plugin_name()const override;
std::string plugin_description()const override;
Expand All @@ -49,7 +49,7 @@ class es_objects_plugin : public graphene::app::plugin
void plugin_initialize(const boost::program_options::variables_map& options) override;
void plugin_startup() override;

friend class detail::es_objects_plugin_impl;
private:
std::unique_ptr<detail::es_objects_plugin_impl> my;
};

Expand Down
11 changes: 3 additions & 8 deletions libraries/plugins/grouped_orders/grouped_orders_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ namespace detail
class grouped_orders_plugin_impl
{
public:
grouped_orders_plugin_impl(grouped_orders_plugin& _plugin)
explicit grouped_orders_plugin_impl(grouped_orders_plugin& _plugin)
:_self( _plugin ) {}
virtual ~grouped_orders_plugin_impl();

graphene::chain::database& database()
{
Expand Down Expand Up @@ -235,21 +234,17 @@ void limit_order_group_index::remove_order( const limit_order_object& o, bool re
}
}

grouped_orders_plugin_impl::~grouped_orders_plugin_impl()
{}

} // end namespace detail


grouped_orders_plugin::grouped_orders_plugin(graphene::app::application& app) :
plugin(app),
my( std::make_unique<detail::grouped_orders_plugin_impl>(*this) )
{
// Nothing else to do
}

grouped_orders_plugin::~grouped_orders_plugin()
{
}
grouped_orders_plugin::~grouped_orders_plugin() = default;

std::string grouped_orders_plugin::plugin_name()const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace detail
class grouped_orders_plugin : public graphene::app::plugin
{
public:
grouped_orders_plugin(graphene::app::application& app);
explicit grouped_orders_plugin(graphene::app::application& app);
~grouped_orders_plugin() override;

std::string plugin_name()const override;
Expand All @@ -85,7 +85,6 @@ class grouped_orders_plugin : public graphene::app::plugin
const map< limit_order_group_key, limit_order_group_data >& limit_order_groups();

private:
friend class detail::grouped_orders_plugin_impl;
std::unique_ptr<detail::grouped_orders_plugin_impl> my;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ namespace detail
class market_history_plugin : public graphene::app::plugin
{
public:
market_history_plugin(graphene::app::application& app);
explicit market_history_plugin(graphene::app::application& app);
~market_history_plugin() override;

std::string plugin_name()const override;
Expand All @@ -397,7 +397,6 @@ class market_history_plugin : public graphene::app::plugin
uint32_t max_order_his_seconds_per_market()const;

private:
friend class detail::market_history_plugin_impl;
std::unique_ptr<detail::market_history_plugin_impl> my;
};

Expand Down
Loading

0 comments on commit 52ebad4

Please sign in to comment.