diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 6cc26d2375..5471a42382 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -706,7 +706,7 @@ class producer_plugin_impl : public std::enable_shared_from_this _timer_thread; - boost::asio::deadline_timer _timer{_timer_thread.get_executor()}; + boost::asio::system_timer _timer{_timer_thread.get_executor()}; using signature_provider_type = signature_provider_plugin::signature_provider_type; std::map _signature_providers; @@ -826,7 +826,7 @@ class producer_plugin_impl : public std::enable_shared_from_this fc::time_point::now()) { // ship this block off no later than its deadline EOS_ASSERT(chain.is_building_block(), missing_pending_block_state, "producing without pending_block_state, start_block succeeded"); - _timer.expires_at(epoch + boost::posix_time::microseconds(deadline.time_since_epoch().count())); + std::chrono::time_point wake_time{std::chrono::microseconds{deadline.time_since_epoch().count()}}; + _timer.expires_at(wake_time); fc_dlog(_log, "Scheduling Block Production on Normal Block #${num} for ${time}", ("num", chain.head().block_num() + 1)("time", deadline)); } else { EOS_ASSERT(chain.is_building_block(), missing_pending_block_state, "producing without pending_block_state"); - _timer.expires_from_now(boost::posix_time::microseconds(0)); + _timer.expires_after(std::chrono::microseconds(0)); fc_dlog(_log, "Scheduling Block Production on ${desc} Block #${num} immediately", ("num", chain.head().block_num() + 1)("desc", block_is_exhausted() ? "Exhausted" : "Deadline exceeded")); } @@ -2911,8 +2911,8 @@ void producer_plugin_impl::schedule_delayed_production_loop(const std::weak_ptr< std::optional wake_up_time) { if (wake_up_time) { fc_dlog(_log, "Scheduling Speculative/Production Change at ${time}", ("time", wake_up_time)); - static const boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1)); - _timer.expires_at(epoch + boost::posix_time::microseconds(wake_up_time->time_since_epoch().count())); + std::chrono::time_point wake_time{std::chrono::microseconds{wake_up_time->time_since_epoch().count()}}; + _timer.expires_at(wake_time); _timer.async_wait([this, cid = ++_timer_corelation_id](const boost::system::error_code& ec) { if (ec != boost::asio::error::operation_aborted && cid == _timer_corelation_id) { interrupt_transaction(controller::interrupt_t::all_trx); @@ -3108,8 +3108,8 @@ void producer_plugin_impl::start_write_window() { _time_tracker.unpause(now); _ro_window_deadline = now + _ro_write_window_time_us; // not allowed on block producers, so no need to limit to block deadline - auto expire_time = boost::posix_time::microseconds(_ro_write_window_time_us.count()); - _ro_timer.expires_from_now(expire_time); + auto expire_time = std::chrono::microseconds(_ro_write_window_time_us.count()); + _ro_timer.expires_after(expire_time); _ro_timer.async_wait([this](const boost::system::error_code& ec) { if (ec != boost::asio::error::operation_aborted) { app().executor().post(priority::high, exec_queue::read_write, // placed in read_write so only called from main thread @@ -3154,8 +3154,8 @@ void producer_plugin_impl::switch_to_read_window() { _ro_thread_pool.get_executor(), [self = this, pending_block_num]() { return self->read_only_execution_task(pending_block_num); })); } - auto expire_time = boost::posix_time::microseconds(_ro_read_window_time_us.count()); - _ro_timer.expires_from_now(expire_time); + auto expire_time = std::chrono::microseconds(_ro_read_window_time_us.count()); + _ro_timer.expires_after(expire_time); // Needs to be on read_only because that is what is being processed until switch_to_write_window(). _ro_timer.async_wait([this](const boost::system::error_code& ec) { app().executor().post(priority::high, exec_queue::read_only, [this, ec]() {