Skip to content

Commit

Permalink
Merge pull request #328 from eosnetworkfoundation/elmato/remove-block…
Browse files Browse the repository at this point in the history
…-ack-request

[1.0] Remove blocks ack request from ship client
  • Loading branch information
elmato authored Nov 22, 2024
2 parents 2b89399 + 6176a17 commit 7eee6dc
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/ship_receiver_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
eosio::ship_protocol::request req = eosio::ship_protocol::get_blocks_request_v0{
.start_block_num = start,
.end_block_num = std::numeric_limits<uint32_t>::max(),
.max_messages_in_flight = 4*1024,
.max_messages_in_flight = std::numeric_limits<uint32_t>::max(),
.have_positions = {},
.irreversible_only = false,
.fetch_block = true,
Expand All @@ -133,11 +133,6 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
return send_request(req);
}

auto send_get_blocks_ack_request(uint32_t num_messages) {
eosio::ship_protocol::request req = eosio::ship_protocol::get_blocks_ack_request_v0{num_messages};
return send_request(req);
}

template <typename Buffer>
eosio::ship_protocol::result get_result(Buffer&& b){
auto data = b->data();
Expand Down Expand Up @@ -348,12 +343,10 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
}

void start_read() {
static size_t num_messages = 0;
async_read([this](const auto ec, auto buff) {
if (ec) {
SILK_INFO << "Trying to recover from SHiP read failure.";
// Reconnect and restart sync.
num_messages = 0;
reset_connection();
return;
}
Expand All @@ -371,16 +364,6 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu

native_blocks_channel.publish(80, std::make_shared<channels::native_block>(std::move(*block)));

if(++num_messages % 1024 == 0) {
//SILK_INFO << "Block #" << block->block_num;
auto ec = send_get_blocks_ack_request(num_messages);
if (ec) {
num_messages = 0;
reset_connection();
return;
}
}

start_read();
});
}
Expand Down

0 comments on commit 7eee6dc

Please sign in to comment.