Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
fix streaming reset
Browse files Browse the repository at this point in the history
leordev committed May 5, 2020
1 parent b011a7b commit 0e1c4d2
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions programs/rodeos/cloner_plugin.cpp
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ struct cloner_plugin_impl : std::enable_shared_from_this<cloner_plugin_impl> {
std::shared_ptr<cloner_config> config = std::make_shared<cloner_config>();
std::shared_ptr<cloner_session> session;
boost::asio::deadline_timer timer;
std::optional<std::function<void(const char* data, uint64_t data_size)>> 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<ship_client::connection> connection;
bool reported_block = false;
std::unique_ptr<rodeos_filter> filter = {}; // todo: remove
std::optional<std::function<void(const char* data, uint64_t data_size)>> 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<void(const char* data, uint64_t data_size)> streamer_func) {
if (my->session)
my->session->streamer = streamer_func;
my->streamer = streamer_func;
}

} // namespace b1
2 changes: 1 addition & 1 deletion programs/rodeos/streamer_plugin.cpp
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ void streamer_plugin::plugin_initialize(const variables_map& options) {
void streamer_plugin::plugin_startup() {
cloner_plugin* cloner = app().find_plugin<cloner_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); });
}
}

4 changes: 3 additions & 1 deletion programs/rodeos/streams/logger.hpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,9 @@ class logger : public stream_handler {
std::vector<eosio::name> routes_;

public:
logger(std::vector<eosio::name> routes) : routes_(routes) {}
logger(std::vector<eosio::name> routes) : routes_(routes) {
ilog("logger initialized");
}

std::vector<eosio::name>& get_routes() { return routes_; }

0 comments on commit 0e1c4d2

Please sign in to comment.