Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated bulk_pull_blocks #1615

Merged
merged 1 commit into from Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions nano/core_test/message_parser.cpp
Expand Up @@ -13,7 +13,6 @@ class test_visitor : public nano::message_visitor
confirm_ack_count (0),
bulk_pull_count (0),
bulk_pull_account_count (0),
bulk_pull_blocks_count (0),
bulk_push_count (0),
frontier_req_count (0)
{
Expand Down Expand Up @@ -42,10 +41,6 @@ class test_visitor : public nano::message_visitor
{
++bulk_pull_account_count;
}
void bulk_pull_blocks (nano::bulk_pull_blocks const &) override
{
++bulk_pull_blocks_count;
}
void bulk_push (nano::bulk_push const &) override
{
++bulk_push_count;
Expand All @@ -64,7 +59,6 @@ class test_visitor : public nano::message_visitor
uint64_t confirm_ack_count;
uint64_t bulk_pull_count;
uint64_t bulk_pull_account_count;
uint64_t bulk_pull_blocks_count;
uint64_t bulk_push_count;
uint64_t frontier_req_count;
uint64_t node_id_handshake_count;
Expand Down
77 changes: 0 additions & 77 deletions nano/node/bootstrap.cpp
Expand Up @@ -2018,19 +2018,6 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
});
break;
}
case nano::message_type::bulk_pull_blocks:
{
if (node->config.logging.network_logging ())
{
BOOST_LOG (node->log) << boost::str (boost::format ("Received deprecated \"bulk_pull_block\" from bootstrap connection %1%") % static_cast<uint8_t> (header.type));
}

auto this_l (shared_from_this ());
socket->async_read (receive_buffer, sizeof (nano::uint256_union) + sizeof (nano::uint256_union) + sizeof (bulk_pull_blocks_mode) + sizeof (uint32_t), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
this_l->receive_bulk_pull_blocks_action (ec, size_a, header);
});
break;
}
case nano::message_type::frontier_req:
{
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::frontier_req, nano::stat::dir::in);
Expand Down Expand Up @@ -2105,25 +2092,6 @@ void nano::bootstrap_server::receive_bulk_pull_account_action (boost::system::er
}
}

void nano::bootstrap_server::receive_bulk_pull_blocks_action (boost::system::error_code const & ec, size_t size_a, nano::message_header const & header_a)
{
if (!ec)
{
auto error (false);
nano::bufferstream stream (receive_buffer->data (), sizeof (nano::uint256_union) + sizeof (nano::uint256_union) + sizeof (bulk_pull_blocks_mode) + sizeof (uint32_t));
std::unique_ptr<nano::bulk_pull_blocks> request (new nano::bulk_pull_blocks (error, stream, header_a));
if (!error)
{
if (node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (node->log) << boost::str (boost::format ("Received deprecated bulk pull blocks for %1% to %2%") % request->min_hash.to_string () % request->max_hash.to_string ());
}
add_request (std::unique_ptr<nano::message> (request.release ()));
receive ();
}
}
}

void nano::bootstrap_server::receive_frontier_req_action (boost::system::error_code const & ec, size_t size_a, nano::message_header const & header_a)
{
if (!ec)
Expand Down Expand Up @@ -2207,11 +2175,6 @@ class request_response_visitor : public nano::message_visitor
auto response (std::make_shared<nano::bulk_pull_account_server> (connection, std::unique_ptr<nano::bulk_pull_account> (static_cast<nano::bulk_pull_account *> (connection->requests.front ().release ()))));
response->send_frontier ();
}
void bulk_pull_blocks (nano::bulk_pull_blocks const &) override
{
auto response (std::make_shared<nano::bulk_pull_blocks_server> (connection, std::unique_ptr<nano::bulk_pull_blocks> (static_cast<nano::bulk_pull_blocks *> (connection->requests.front ().release ()))));
response->send_next ();
}
void bulk_push (nano::bulk_push const &) override
{
auto response (std::make_shared<nano::bulk_push_server> (connection));
Expand Down Expand Up @@ -2810,46 +2773,6 @@ current_key (0, 0)
set_params ();
}

/**
* DEPRECATED
*/
void nano::bulk_pull_blocks_server::set_params ()
{
assert (request != nullptr);
}

void nano::bulk_pull_blocks_server::send_next ()
{
send_finished ();
}

void nano::bulk_pull_blocks_server::send_finished ()
{
send_buffer->clear ();
send_buffer->push_back (static_cast<uint8_t> (nano::block_type::not_a_block));
auto this_l (shared_from_this ());
connection->socket->async_write (send_buffer, [this_l](boost::system::error_code const & ec, size_t size_a) {
this_l->no_block_sent (ec, size_a);
});
}

void nano::bulk_pull_blocks_server::no_block_sent (boost::system::error_code const & ec, size_t size_a)
{
if (!ec)
{
assert (size_a == 1);
connection->finish_request ();
}
}

nano::bulk_pull_blocks_server::bulk_pull_blocks_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::bulk_pull_blocks> request_a) :
connection (connection_a),
request (std::move (request_a)),
send_buffer (std::make_shared<std::vector<uint8_t>> ())
{
set_params ();
}

nano::bulk_push_server::bulk_push_server (std::shared_ptr<nano::bootstrap_server> const & connection_a) :
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
connection (connection_a)
Expand Down
19 changes: 0 additions & 19 deletions nano/node/bootstrap.hpp
Expand Up @@ -142,10 +142,8 @@ class frontier_req_client : public std::enable_shared_from_this<nano::frontier_r
void run ();
void receive_frontier ();
void received_frontier (boost::system::error_code const &, size_t);
void request_account (nano::account const &, nano::block_hash const &);
void unsynced (nano::block_hash const &, nano::block_hash const &);
void next (nano::transaction const &);
void insert_pull (nano::pull_info const &);
std::shared_ptr<nano::bootstrap_client> connection;
nano::account current;
nano::block_hash frontier;
Expand Down Expand Up @@ -271,9 +269,7 @@ class bootstrap_server : public std::enable_shared_from_this<nano::bootstrap_ser
void receive_header_action (boost::system::error_code const &, size_t);
void receive_bulk_pull_action (boost::system::error_code const &, size_t, nano::message_header const &);
void receive_bulk_pull_account_action (boost::system::error_code const &, size_t, nano::message_header const &);
void receive_bulk_pull_blocks_action (boost::system::error_code const &, size_t, nano::message_header const &);
void receive_frontier_req_action (boost::system::error_code const &, size_t, nano::message_header const &);
void receive_bulk_push_action ();
void add_request (std::unique_ptr<nano::message>);
void finish_request ();
void run_next ();
Expand Down Expand Up @@ -323,26 +319,11 @@ class bulk_pull_account_server : public std::enable_shared_from_this<nano::bulk_
bool pending_include_address;
bool invalid_request;
};
class bulk_pull_blocks;
class bulk_pull_blocks_server : public std::enable_shared_from_this<nano::bulk_pull_blocks_server>
{
public:
bulk_pull_blocks_server (std::shared_ptr<nano::bootstrap_server> const &, std::unique_ptr<nano::bulk_pull_blocks>);
void set_params ();
std::shared_ptr<nano::block> get_next ();
void send_next ();
void send_finished ();
void no_block_sent (boost::system::error_code const &, size_t);
std::shared_ptr<nano::bootstrap_server> connection;
std::unique_ptr<nano::bulk_pull_blocks> request;
std::shared_ptr<std::vector<uint8_t>> send_buffer;
};
class bulk_push_server : public std::enable_shared_from_this<nano::bulk_push_server>
{
public:
bulk_push_server (std::shared_ptr<nano::bootstrap_server> const &);
void receive ();
void receive_block ();
void received_type ();
void received_block (boost::system::error_code const &, size_t, nano::block_type);
std::shared_ptr<std::vector<uint8_t>> receive_buffer;
Expand Down
47 changes: 0 additions & 47 deletions nano/node/common.cpp
Expand Up @@ -713,53 +713,6 @@ void nano::bulk_pull_account::serialize (nano::stream & stream_a) const
write (stream_a, flags);
}

nano::bulk_pull_blocks::bulk_pull_blocks () :
message (nano::message_type::bulk_pull_blocks)
{
}

nano::bulk_pull_blocks::bulk_pull_blocks (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
message (header_a)
{
if (!error_a)
{
error_a = deserialize (stream_a);
}
}

void nano::bulk_pull_blocks::visit (nano::message_visitor & visitor_a) const
{
visitor_a.bulk_pull_blocks (*this);
}

bool nano::bulk_pull_blocks::deserialize (nano::stream & stream_a)
{
assert (header.type == nano::message_type::bulk_pull_blocks);
auto result (read (stream_a, min_hash));
if (!result)
{
result = read (stream_a, max_hash);
if (!result)
{
result = read (stream_a, mode);
if (!result)
{
result = read (stream_a, max_count);
}
}
}
return result;
}

void nano::bulk_pull_blocks::serialize (nano::stream & stream_a) const
{
header.serialize (stream_a);
write (stream_a, min_hash);
write (stream_a, max_hash);
write (stream_a, mode);
write (stream_a, max_count);
}

nano::bulk_push::bulk_push () :
message (nano::message_type::bulk_push)
{
Expand Down
21 changes: 1 addition & 20 deletions nano/node/common.hpp
Expand Up @@ -144,15 +144,10 @@ enum class message_type : uint8_t
bulk_pull = 0x6,
bulk_push = 0x7,
frontier_req = 0x8,
bulk_pull_blocks = 0x9,
/* deleted 0x9 */
node_id_handshake = 0x0a,
bulk_pull_account = 0x0b
};
enum class bulk_pull_blocks_mode : uint8_t
{
list_blocks,
checksum_blocks
};
enum class bulk_pull_account_flags : uint8_t
{
pending_hash_and_amount = 0x0,
Expand Down Expand Up @@ -332,19 +327,6 @@ class bulk_pull_account : public message
nano::uint128_union minimum_amount;
bulk_pull_account_flags flags;
};
class bulk_pull_blocks : public message
{
public:
bulk_pull_blocks ();
bulk_pull_blocks (bool &, nano::stream &, nano::message_header const &);
bool deserialize (nano::stream &);
void serialize (nano::stream &) const override;
void visit (nano::message_visitor &) const override;
nano::block_hash min_hash;
nano::block_hash max_hash;
bulk_pull_blocks_mode mode;
uint32_t max_count;
};
class bulk_push : public message
{
public:
Expand Down Expand Up @@ -381,7 +363,6 @@ class message_visitor
virtual void confirm_ack (nano::confirm_ack const &) = 0;
virtual void bulk_pull (nano::bulk_pull const &) = 0;
virtual void bulk_pull_account (nano::bulk_pull_account const &) = 0;
virtual void bulk_pull_blocks (nano::bulk_pull_blocks const &) = 0;
virtual void bulk_push (nano::bulk_push const &) = 0;
virtual void frontier_req (nano::frontier_req const &) = 0;
virtual void node_id_handshake (nano::node_id_handshake const &) = 0;
Expand Down
4 changes: 0 additions & 4 deletions nano/node/node.cpp
Expand Up @@ -556,10 +556,6 @@ class network_message_visitor : public nano::message_visitor
{
assert (false);
}
void bulk_pull_blocks (nano::bulk_pull_blocks const &) override
{
assert (false);
}
void bulk_push (nano::bulk_push const &) override
{
assert (false);
Expand Down