Removing unnecessary check for running within unit test context and associated static instantiation of network_constants. No appreciable difference in unit test speed.

This commit is contained in:
clemahieu 2021-08-09 09:56:51 +01:00
commit 9d47208735
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
2 changed files with 23 additions and 28 deletions

View file

@ -36,38 +36,34 @@ void nano::logging::init (boost::filesystem::path const & application_path_a)
boost::log::add_console_log (std::cerr, boost::log::keywords::format = format_with_timestamp);
}
nano::network_constants network_constants;
if (!network_constants.is_dev_network ())
{
#ifdef BOOST_WINDOWS
if (nano::event_log_reg_entry_exists () || nano::is_windows_elevated ())
{
static auto event_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::simple_event_log_backend>> (boost::log::keywords::log_name = "Nano", boost::log::keywords::log_source = "Nano");
event_sink->set_formatter (format);
// Currently only mapping sys log errors
boost::log::sinks::event_log::custom_event_type_mapping<nano::severity_level> mapping ("Severity");
mapping[nano::severity_level::error] = boost::log::sinks::event_log::error;
event_sink->locked_backend ()->set_event_type_mapper (mapping);
// Only allow messages or error or greater severity to the event log
event_sink->set_filter (severity >= nano::severity_level::error);
boost::log::core::get ()->add_sink (event_sink);
}
#else
static auto sys_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::syslog_backend>> (boost::log::keywords::facility = boost::log::sinks::syslog::user, boost::log::keywords::use_impl = boost::log::sinks::syslog::impl_types::native);
sys_sink->set_formatter (format);
if (nano::event_log_reg_entry_exists () || nano::is_windows_elevated ())
{
static auto event_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::simple_event_log_backend>> (boost::log::keywords::log_name = "Nano", boost::log::keywords::log_source = "Nano");
event_sink->set_formatter (format);
// Currently only mapping sys log errors
boost::log::sinks::syslog::custom_severity_mapping<nano::severity_level> mapping ("Severity");
mapping[nano::severity_level::error] = boost::log::sinks::syslog::error;
sys_sink->locked_backend ()->set_severity_mapper (mapping);
boost::log::sinks::event_log::custom_event_type_mapping<nano::severity_level> mapping ("Severity");
mapping[nano::severity_level::error] = boost::log::sinks::event_log::error;
event_sink->locked_backend ()->set_event_type_mapper (mapping);
// Only allow messages or error or greater severity to the sys log
sys_sink->set_filter (severity >= nano::severity_level::error);
boost::log::core::get ()->add_sink (sys_sink);
#endif
// Only allow messages or error or greater severity to the event log
event_sink->set_filter (severity >= nano::severity_level::error);
boost::log::core::get ()->add_sink (event_sink);
}
#else
static auto sys_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::syslog_backend>> (boost::log::keywords::facility = boost::log::sinks::syslog::user, boost::log::keywords::use_impl = boost::log::sinks::syslog::impl_types::native);
sys_sink->set_formatter (format);
// Currently only mapping sys log errors
boost::log::sinks::syslog::custom_severity_mapping<nano::severity_level> mapping ("Severity");
mapping[nano::severity_level::error] = boost::log::sinks::syslog::error;
sys_sink->locked_backend ()->set_severity_mapper (mapping);
// Only allow messages or error or greater severity to the sys log
sys_sink->set_filter (severity >= nano::severity_level::error);
boost::log::core::get ()->add_sink (sys_sink);
#endif
//clang-format off
#if BOOST_VERSION < 107000

View file

@ -863,7 +863,6 @@ nano::uint128_t nano::ledger::account_pending (nano::transaction const & transac
nano::process_return nano::ledger::process (nano::write_transaction const & transaction_a, nano::block & block_a, nano::signature_verification verification)
{
static nano::network_constants network_constants;
debug_assert (!constants.work.validate_entry (block_a) || constants.genesis == nano::dev::genesis);
ledger_processor processor (*this, transaction_a, verification);
block_a.visit (processor);