Skip to content

Commit

Permalink
fix issue #592
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Dec 28, 2022
1 parent 2f01e9e commit 9fba5f1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
}
socket_stream.next_layer().set_option(boost::asio::socket_base::send_buffer_size(1024 * 1024));
socket_stream.next_layer().set_option(boost::asio::socket_base::receive_buffer_size(1024 * 1024));

socket_stream.async_accept([self = this->shared_from_this()](boost::system::error_code ec) {
self->callback(ec, "async_accept", [self] {
self->start_read();
self->send(state_history_plugin_abi);
});
});
}


void start_read() {
auto in_buffer = std::make_shared<boost::beast::flat_buffer>();
Expand All @@ -186,12 +186,14 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
});
}


void send() {
if (sending)
return;
if (send_queue.empty())
return send_update();
if (send_queue.empty()) {
app().post(priority::medium, [self = this->shared_from_this()]() { self->send_update(); });
return;
}
sending = true;
socket_stream.binary(sent_abi);
sent_abi = true;
Expand Down Expand Up @@ -220,7 +222,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
self->send();
});
}

using result_type = void;
void operator()(get_status_request_v0&) {
fc_ilog(_log, "got get_status_request_v0");
Expand Down Expand Up @@ -254,7 +256,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this<state_history_pl
fc_dlog(_log, "block ${block_num} is not available", ("block_num", cp.block_num));
} else if (*id != cp.block_id) {
fc_dlog(_log, "the id for block ${block_num} in block request have_positions does not match the existing", ("block_num", cp.block_num));
}
}
}
req.have_positions.clear();
fc_dlog(_log, " get_blocks_request_v0 start_block_num set to ${num}", ("num", req.start_block_num));
Expand Down

0 comments on commit 9fba5f1

Please sign in to comment.