Remove callbacks passed through start_tcp as they're no longer used.
This commit is contained in:
parent
809e50bf5d
commit
e1786a40f0
2 changed files with 24 additions and 32 deletions
|
|
@ -516,11 +516,11 @@ void nano::transport::tcp_channels::update (nano::tcp_endpoint const & endpoint_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const & callback_a)
|
void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a)
|
||||||
{
|
{
|
||||||
if (node.flags.disable_tcp_realtime)
|
if (node.flags.disable_tcp_realtime)
|
||||||
{
|
{
|
||||||
node.network.tcp_channels.udp_fallback (endpoint_a, callback_a);
|
node.network.tcp_channels.udp_fallback (endpoint_a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto socket = std::make_shared<nano::socket> (node, boost::none);
|
auto socket = std::make_shared<nano::socket> (node, boost::none);
|
||||||
|
|
@ -528,7 +528,7 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
|
||||||
auto channel (std::make_shared<nano::transport::channel_tcp> (node, socket_w));
|
auto channel (std::make_shared<nano::transport::channel_tcp> (node, socket_w));
|
||||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||||
socket->async_connect (nano::transport::map_endpoint_to_tcp (endpoint_a),
|
socket->async_connect (nano::transport::map_endpoint_to_tcp (endpoint_a),
|
||||||
[node_w, channel, socket, endpoint_a, callback_a] (boost::system::error_code const & ec) {
|
[node_w, channel, socket, endpoint_a] (boost::system::error_code const & ec) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
if (!ec && channel)
|
if (!ec && channel)
|
||||||
|
|
@ -543,12 +543,12 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
|
||||||
channel->set_endpoint ();
|
channel->set_endpoint ();
|
||||||
std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
|
std::shared_ptr<std::vector<uint8_t>> receive_buffer (std::make_shared<std::vector<uint8_t>> ());
|
||||||
receive_buffer->resize (256);
|
receive_buffer->resize (256);
|
||||||
channel->send (message, [node_w, channel, endpoint_a, receive_buffer, callback_a] (boost::system::error_code const & ec, size_t size_a) {
|
channel->send (message, [node_w, channel, endpoint_a, receive_buffer] (boost::system::error_code const & ec, size_t size_a) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
if (!ec)
|
if (!ec)
|
||||||
{
|
{
|
||||||
node_l->network.tcp_channels.start_tcp_receive_node_id (channel, endpoint_a, receive_buffer, callback_a);
|
node_l->network.tcp_channels.start_tcp_receive_node_id (channel, endpoint_a, receive_buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -560,25 +560,25 @@ void nano::transport::tcp_channels::start_tcp (nano::endpoint const & endpoint_a
|
||||||
{
|
{
|
||||||
node_l->logger.try_log (boost::str (boost::format ("Error sending node_id_handshake to %1%: %2%") % endpoint_a % ec.message ()));
|
node_l->logger.try_log (boost::str (boost::format ("Error sending node_id_handshake to %1%: %2%") % endpoint_a % ec.message ()));
|
||||||
}
|
}
|
||||||
node_l->network.tcp_channels.udp_fallback (endpoint_a, callback_a);
|
node_l->network.tcp_channels.udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node_l->network.tcp_channels.udp_fallback (endpoint_a, callback_a);
|
node_l->network.tcp_channels.udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp> const & channel_a, nano::endpoint const & endpoint_a, std::shared_ptr<std::vector<uint8_t>> const & receive_buffer_a, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const & callback_a)
|
void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp> const & channel_a, nano::endpoint const & endpoint_a, std::shared_ptr<std::vector<uint8_t>> const & receive_buffer_a)
|
||||||
{
|
{
|
||||||
std::weak_ptr<nano::node> node_w (node.shared ());
|
std::weak_ptr<nano::node> node_w (node.shared ());
|
||||||
if (auto socket_l = channel_a->socket.lock ())
|
if (auto socket_l = channel_a->socket.lock ())
|
||||||
{
|
{
|
||||||
auto cleanup_node_id_handshake_socket = [socket_w = channel_a->socket, node_w] (nano::endpoint const & endpoint_a, std::function<void (std::shared_ptr<nano::transport::channel>)> const & callback_a) {
|
auto cleanup_node_id_handshake_socket = [socket_w = channel_a->socket, node_w] (nano::endpoint const & endpoint_a) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
if (auto socket_l = socket_w.lock ())
|
if (auto socket_l = socket_w.lock ())
|
||||||
|
|
@ -588,15 +588,15 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto cleanup_and_udp_fallback = [socket_w = channel_a->socket, node_w, cleanup_node_id_handshake_socket] (nano::endpoint const & endpoint_a, std::function<void (std::shared_ptr<nano::transport::channel>)> const & callback_a) {
|
auto cleanup_and_udp_fallback = [socket_w = channel_a->socket, node_w, cleanup_node_id_handshake_socket] (nano::endpoint const & endpoint_a) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
node_l->network.tcp_channels.udp_fallback (endpoint_a, callback_a);
|
node_l->network.tcp_channels.udp_fallback (endpoint_a);
|
||||||
cleanup_node_id_handshake_socket (endpoint_a, callback_a);
|
cleanup_node_id_handshake_socket (endpoint_a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket_l->async_read (receive_buffer_a, 8 + sizeof (nano::account) + sizeof (nano::account) + sizeof (nano::signature), [node_w, channel_a, endpoint_a, receive_buffer_a, callback_a, cleanup_and_udp_fallback, cleanup_node_id_handshake_socket] (boost::system::error_code const & ec, size_t size_a) {
|
socket_l->async_read (receive_buffer_a, 8 + sizeof (nano::account) + sizeof (nano::account) + sizeof (nano::signature), [node_w, channel_a, endpoint_a, receive_buffer_a, cleanup_and_udp_fallback, cleanup_node_id_handshake_socket] (boost::system::error_code const & ec, size_t size_a) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
if (!ec && channel_a)
|
if (!ec && channel_a)
|
||||||
|
|
@ -635,7 +635,7 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
{
|
{
|
||||||
node_l->logger.try_log (boost::str (boost::format ("Node ID handshake response sent with node ID %1% to %2%: query %3%") % node_l->node_id.pub.to_node_id () % endpoint_a % (*message.query).to_string ()));
|
node_l->logger.try_log (boost::str (boost::format ("Node ID handshake response sent with node ID %1% to %2%: query %3%") % node_l->node_id.pub.to_node_id () % endpoint_a % (*message.query).to_string ()));
|
||||||
}
|
}
|
||||||
channel_a->send (response_message, [node_w, channel_a, endpoint_a, callback_a, cleanup_and_udp_fallback] (boost::system::error_code const & ec, size_t size_a) {
|
channel_a->send (response_message, [node_w, channel_a, endpoint_a, cleanup_and_udp_fallback] (boost::system::error_code const & ec, size_t size_a) {
|
||||||
if (auto node_l = node_w.lock ())
|
if (auto node_l = node_w.lock ())
|
||||||
{
|
{
|
||||||
if (!ec && channel_a)
|
if (!ec && channel_a)
|
||||||
|
|
@ -646,10 +646,6 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
channel_a->set_last_packet_sent (std::chrono::steady_clock::now ());
|
channel_a->set_last_packet_sent (std::chrono::steady_clock::now ());
|
||||||
auto response_server = std::make_shared<nano::bootstrap_server> (socket_l, node_l);
|
auto response_server = std::make_shared<nano::bootstrap_server> (socket_l, node_l);
|
||||||
node_l->network.tcp_channels.insert (channel_a, socket_l, response_server);
|
node_l->network.tcp_channels.insert (channel_a, socket_l, response_server);
|
||||||
if (callback_a)
|
|
||||||
{
|
|
||||||
callback_a (channel_a);
|
|
||||||
}
|
|
||||||
// Listen for possible responses
|
// Listen for possible responses
|
||||||
response_server->socket->type_set (nano::socket::type_t::realtime_response_server);
|
response_server->socket->type_set (nano::socket::type_t::realtime_response_server);
|
||||||
response_server->remote_node_id = channel_a->get_node_id ();
|
response_server->remote_node_id = channel_a->get_node_id ();
|
||||||
|
|
@ -669,7 +665,7 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
{
|
{
|
||||||
node_l->logger.try_log (boost::str (boost::format ("Error sending node_id_handshake to %1%: %2%") % endpoint_a % ec.message ()));
|
node_l->logger.try_log (boost::str (boost::format ("Error sending node_id_handshake to %1%: %2%") % endpoint_a % ec.message ()));
|
||||||
}
|
}
|
||||||
cleanup_and_udp_fallback (endpoint_a, callback_a);
|
cleanup_and_udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -677,13 +673,13 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cleanup_and_udp_fallback (endpoint_a, callback_a);
|
cleanup_and_udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Version of channel is not high enough, just abort. Don't fallback to udp, instead cleanup attempt
|
// Version of channel is not high enough, just abort. Don't fallback to udp, instead cleanup attempt
|
||||||
cleanup_node_id_handshake_socket (endpoint_a, callback_a);
|
cleanup_node_id_handshake_socket (endpoint_a);
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lock (node_l->network.tcp_channels.mutex);
|
nano::lock_guard<nano::mutex> lock (node_l->network.tcp_channels.mutex);
|
||||||
node_l->network.tcp_channels.attempts.get<endpoint_tag> ().erase (nano::transport::map_endpoint_to_tcp (endpoint_a));
|
node_l->network.tcp_channels.attempts.get<endpoint_tag> ().erase (nano::transport::map_endpoint_to_tcp (endpoint_a));
|
||||||
|
|
@ -692,7 +688,7 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cleanup_and_udp_fallback (endpoint_a, callback_a);
|
cleanup_and_udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -701,14 +697,14 @@ void nano::transport::tcp_channels::start_tcp_receive_node_id (std::shared_ptr<n
|
||||||
{
|
{
|
||||||
node_l->logger.try_log (boost::str (boost::format ("Error reading node_id_handshake from %1%: %2%") % endpoint_a % ec.message ()));
|
node_l->logger.try_log (boost::str (boost::format ("Error reading node_id_handshake from %1%: %2%") % endpoint_a % ec.message ()));
|
||||||
}
|
}
|
||||||
cleanup_and_udp_fallback (endpoint_a, callback_a);
|
cleanup_and_udp_fallback (endpoint_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nano::transport::tcp_channels::udp_fallback (nano::endpoint const & endpoint_a, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const & callback_a)
|
void nano::transport::tcp_channels::udp_fallback (nano::endpoint const & endpoint_a)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
nano::lock_guard<nano::mutex> lock (mutex);
|
nano::lock_guard<nano::mutex> lock (mutex);
|
||||||
|
|
@ -716,11 +712,7 @@ void nano::transport::tcp_channels::udp_fallback (nano::endpoint const & endpoin
|
||||||
}
|
}
|
||||||
if (!node.flags.disable_udp)
|
if (!node.flags.disable_udp)
|
||||||
{
|
{
|
||||||
auto channel_udp (node.network.udp_channels.create (endpoint_a));
|
auto channel_udp = node.network.udp_channels.create (endpoint_a);
|
||||||
node.network.send_keepalive (channel_udp);
|
node.network.send_keepalive (channel_udp);
|
||||||
if (callback_a)
|
|
||||||
{
|
|
||||||
callback_a (channel_udp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,9 @@ namespace transport
|
||||||
void modify (std::shared_ptr<nano::transport::channel_tcp> const &, std::function<void (std::shared_ptr<nano::transport::channel_tcp> const &)>);
|
void modify (std::shared_ptr<nano::transport::channel_tcp> const &, std::function<void (std::shared_ptr<nano::transport::channel_tcp> const &)>);
|
||||||
void update (nano::tcp_endpoint const &);
|
void update (nano::tcp_endpoint const &);
|
||||||
// Connection start
|
// Connection start
|
||||||
void start_tcp (nano::endpoint const &, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const & = nullptr);
|
void start_tcp (nano::endpoint const &);
|
||||||
void start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp> const &, nano::endpoint const &, std::shared_ptr<std::vector<uint8_t>> const &, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const &);
|
void start_tcp_receive_node_id (std::shared_ptr<nano::transport::channel_tcp> const &, nano::endpoint const &, std::shared_ptr<std::vector<uint8_t>> const &);
|
||||||
void udp_fallback (nano::endpoint const &, std::function<void (std::shared_ptr<nano::transport::channel> const &)> const &);
|
void udp_fallback (nano::endpoint const &);
|
||||||
nano::node & node;
|
nano::node & node;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue