From 0e1c4d28f986b0c03c9e98cae06c8e3c26e29df1 Mon Sep 17 00:00:00 2001 From: Leo Ribeiro Date: Fri, 1 May 2020 16:02:51 -0400 Subject: [PATCH] fix streaming reset --- programs/rodeos/cloner_plugin.cpp | 10 +++++----- programs/rodeos/streamer_plugin.cpp | 2 +- programs/rodeos/streams/logger.hpp | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/programs/rodeos/cloner_plugin.cpp b/programs/rodeos/cloner_plugin.cpp index 65ac42a90b7..16f3962fee4 100644 --- a/programs/rodeos/cloner_plugin.cpp +++ b/programs/rodeos/cloner_plugin.cpp @@ -39,6 +39,7 @@ struct cloner_plugin_impl : std::enable_shared_from_this { std::shared_ptr config = std::make_shared(); std::shared_ptr session; boost::asio::deadline_timer timer; + std::optional> streamer = {}; cloner_plugin_impl() : timer(app().get_io_service()) {} @@ -66,7 +67,6 @@ struct cloner_session : ship_client::connection_callbacks, std::enable_shared_fr std::shared_ptr connection; bool reported_block = false; std::unique_ptr filter = {}; // todo: remove - std::optional> streamer = {}; cloner_session(cloner_plugin_impl* my) : my(my), config(my->config) { // todo: remove @@ -158,9 +158,10 @@ struct cloner_session : ship_client::connection_callbacks, std::enable_shared_fr rodeos_snapshot->write_block_info(result); rodeos_snapshot->write_deltas(result, [] { return app().is_quiting(); }); - if (filter && streamer) + if (filter && my->streamer) { filter->process(*rodeos_snapshot, result, bin, - [&](const char* data, uint64_t data_size) { (*streamer)(data, data_size); }); + [&](const char* data, uint64_t data_size) { (*my->streamer)(data, data_size); }); + } rodeos_snapshot->end_block(result, false); return true; @@ -237,8 +238,7 @@ void cloner_plugin::plugin_shutdown() { } void cloner_plugin::set_streamer(std::function streamer_func) { - if (my->session) - my->session->streamer = streamer_func; + my->streamer = streamer_func; } } // namespace b1 diff --git a/programs/rodeos/streamer_plugin.cpp b/programs/rodeos/streamer_plugin.cpp index 411293a9fdd..5b12e8a717e 100644 --- a/programs/rodeos/streamer_plugin.cpp +++ b/programs/rodeos/streamer_plugin.cpp @@ -53,7 +53,7 @@ void streamer_plugin::plugin_initialize(const variables_map& options) { void streamer_plugin::plugin_startup() { cloner_plugin* cloner = app().find_plugin(); if (cloner) { - cloner->set_streamer([&](const char* data, uint64_t data_size) { stream_data(data, data_size); }); + cloner->set_streamer([this](const char* data, uint64_t data_size) { stream_data(data, data_size); }); } } diff --git a/programs/rodeos/streams/logger.hpp b/programs/rodeos/streams/logger.hpp index 922abe85f21..d45e6cb06b0 100644 --- a/programs/rodeos/streams/logger.hpp +++ b/programs/rodeos/streams/logger.hpp @@ -9,7 +9,9 @@ class logger : public stream_handler { std::vector routes_; public: - logger(std::vector routes) : routes_(routes) {} + logger(std::vector routes) : routes_(routes) { + ilog("logger initialized"); + } std::vector& get_routes() { return routes_; }