Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor config options to defines #3106

Open
mvandeberg opened this issue Oct 24, 2018 · 0 comments
Open

Refactor config options to defines #3106

mvandeberg opened this issue Oct 24, 2018 · 0 comments

Comments

@mvandeberg
Copy link
Contributor

There is a bug in the market history plugin

void market_history_plugin::set_program_options(
boost::program_options::options_description& cli,
boost::program_options::options_description& cfg
)
{
cfg.add_options()
("market-history-bucket-size", boost::program_options::value<string>()->default_value("[15,60,300,3600,86400]"),
"Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers")
("market-history-buckets-per-size", boost::program_options::value<uint32_t>()->default_value(5760),
"How far back in time to track history for each bucket size, measured in the number of buckets (default: 5760)")
;
}
void market_history_plugin::plugin_initialize( const boost::program_options::variables_map& options )
{
try
{
ilog( "market_history: plugin_initialize() begin" );
my = std::make_unique< detail::market_history_plugin_impl >();
my->_post_apply_operation_conn = my->_db.add_post_apply_operation_handler( [&]( const operation_notification& note ){ my->on_post_apply_operation( note ); }, *this, 0 );
add_plugin_index< bucket_index >( my->_db );
add_plugin_index< order_history_index >( my->_db );
if( options.count("bucket-size" ) )
{
std::string buckets = options["bucket-size"].as< string >();
my->_tracked_buckets = fc::json::from_string( buckets ).as< flat_set< uint32_t > >();
}
if( options.count("history-per-size" ) )
my->_maximum_history_per_bucket_size = options["history-per-size"].as< uint32_t >();
wlog( "bucket-size ${b}", ("b", my->_tracked_buckets) );
wlog( "history-per-size ${h}", ("h", my->_maximum_history_per_bucket_size) );
ilog( "market_history: plugin_initialize() end" );
} FC_CAPTURE_AND_RETHROW()
}

That would have been avoided if config options were defines instead of string literals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants