mirror of
https://github.com/monero-project/monero.git
synced 2025-07-30 00:08:48 -04:00
Revert "Merge pull request #7136"
This reverts commit63c7ca07fb
, reversing changes made to2218e23e84
.
This commit is contained in:
parent
d544fd0f52
commit
e45619e61e
20 changed files with 215 additions and 319 deletions
|
@ -57,7 +57,6 @@
|
|||
#include "common/notify.h"
|
||||
#include "common/varint.h"
|
||||
#include "common/pruning.h"
|
||||
#include "time_helper.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "blockchain"
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
#include "block_queue.h"
|
||||
#include "common/perf_timer.h"
|
||||
#include "cryptonote_basic/connection_context.h"
|
||||
#include "net/levin_base.h"
|
||||
#include "p2p/net_node_common.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
PUSH_WARNINGS
|
||||
|
@ -197,11 +195,10 @@ namespace cryptonote
|
|||
bool post_notify(typename t_parameter::request& arg, cryptonote_connection_context& context)
|
||||
{
|
||||
LOG_PRINT_L2("[" << epee::net_utils::print_connection_context_short(context) << "] post " << typeid(t_parameter).name() << " -->");
|
||||
|
||||
epee::levin::message_writer out{256 * 1024}; // optimize for block responses
|
||||
epee::serialization::store_t_to_binary(arg, out.buffer);
|
||||
epee::byte_slice blob;
|
||||
epee::serialization::store_t_to_binary(arg, blob, 256 * 1024); // optimize for block responses
|
||||
//handler_response_blocks_now(blob.size()); // XXX
|
||||
return m_p2p->invoke_notify_to_peer(t_parameter::ID, std::move(out), context);
|
||||
return m_p2p->invoke_notify_to_peer(t_parameter::ID, epee::to_span(blob), context);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2713,15 +2713,15 @@ skip:
|
|||
// send fluffy ones first, we want to encourage people to run that
|
||||
if (!fluffyConnections.empty())
|
||||
{
|
||||
epee::levin::message_writer fluffyBlob{32 * 1024};
|
||||
epee::serialization::store_t_to_binary(fluffy_arg, fluffyBlob.buffer);
|
||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, std::move(fluffyBlob), std::move(fluffyConnections));
|
||||
epee::byte_slice fluffyBlob;
|
||||
epee::serialization::store_t_to_binary(fluffy_arg, fluffyBlob, 32 * 1024);
|
||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, epee::to_span(fluffyBlob), std::move(fluffyConnections));
|
||||
}
|
||||
if (!fullConnections.empty())
|
||||
{
|
||||
epee::levin::message_writer fullBlob{128 * 1024};
|
||||
epee::serialization::store_t_to_binary(arg, fullBlob.buffer);
|
||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, std::move(fullBlob), std::move(fullConnections));
|
||||
epee::byte_slice fullBlob;
|
||||
epee::serialization::store_t_to_binary(arg, fullBlob, 128 * 1024);
|
||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, epee::to_span(fullBlob), std::move(fullConnections));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "p2p/net_node_common.h"
|
||||
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
||||
#include "cryptonote_protocol/enums.h"
|
||||
#include "cryptonote_basic/connection_context.h"
|
||||
namespace cryptonote
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace levin
|
|||
return get_out_connections(p2p, get_blockchain_height(p2p, core));
|
||||
}
|
||||
|
||||
epee::levin::message_writer make_tx_message(std::vector<blobdata>&& txs, const bool pad, const bool fluff)
|
||||
epee::byte_slice make_tx_payload(std::vector<blobdata>&& txs, const bool pad, const bool fluff)
|
||||
{
|
||||
NOTIFY_NEW_TRANSACTIONS::request request{};
|
||||
request.txs = std::move(txs);
|
||||
|
@ -193,17 +193,21 @@ namespace levin
|
|||
// if the size of _ moved enough, we might lose byte in size encoding, we don't care
|
||||
}
|
||||
|
||||
epee::levin::message_writer out;
|
||||
if (!epee::serialization::store_t_to_binary(request, out.buffer))
|
||||
epee::byte_slice fullBlob;
|
||||
if (!epee::serialization::store_t_to_binary(request, fullBlob))
|
||||
throw std::runtime_error{"Failed to serialize to epee binary format"};
|
||||
|
||||
return out;
|
||||
return fullBlob;
|
||||
}
|
||||
|
||||
bool make_payload_send_txs(connections& p2p, std::vector<blobdata>&& txs, const boost::uuids::uuid& destination, const bool pad, const bool fluff)
|
||||
{
|
||||
epee::byte_slice blob = make_tx_message(std::move(txs), pad, fluff).finalize_notify(NOTIFY_NEW_TRANSACTIONS::ID);
|
||||
return p2p.send(std::move(blob), destination);
|
||||
const epee::byte_slice blob = make_tx_payload(std::move(txs), pad, fluff);
|
||||
p2p.for_connection(destination, [&blob](detail::p2p_context& context) {
|
||||
on_levin_traffic(context, true, true, false, blob.size(), NOTIFY_NEW_TRANSACTIONS::ID);
|
||||
return true;
|
||||
});
|
||||
return p2p.notify(NOTIFY_NEW_TRANSACTIONS::ID, epee::to_span(blob), destination);
|
||||
}
|
||||
|
||||
/* The current design uses `asio::strand`s. The documentation isn't as clear
|
||||
|
@ -649,6 +653,10 @@ namespace levin
|
|||
else
|
||||
message = zone_->noise.clone();
|
||||
|
||||
zone_->p2p->for_connection(channel.connection, [&](detail::p2p_context& context) {
|
||||
on_levin_traffic(context, true, true, false, message.size(), "noise");
|
||||
return true;
|
||||
});
|
||||
if (zone_->p2p->send(std::move(message), channel.connection))
|
||||
{
|
||||
if (!channel.queue.empty() && channel.active.empty())
|
||||
|
@ -808,8 +816,9 @@ namespace levin
|
|||
|
||||
// Padding is not useful when using noise mode. Send as stem so receiver
|
||||
// forwards in Dandelion++ mode.
|
||||
const epee::byte_slice payload = make_tx_payload(std::move(txs), false, false);
|
||||
epee::byte_slice message = epee::levin::make_fragmented_notify(
|
||||
zone_->noise.size(), NOTIFY_NEW_TRANSACTIONS::ID, make_tx_message(std::move(txs), false, false)
|
||||
zone_->noise, NOTIFY_NEW_TRANSACTIONS::ID, epee::to_span(payload)
|
||||
);
|
||||
if (CRYPTONOTE_MAX_FRAGMENTS * zone_->noise.size() < message.size())
|
||||
{
|
||||
|
|
|
@ -344,9 +344,10 @@ namespace nodetool
|
|||
virtual void on_connection_close(p2p_connection_context& context);
|
||||
virtual void callback(p2p_connection_context& context);
|
||||
//----------------- i_p2p_endpoint -------------------------------------------------------------
|
||||
virtual bool relay_notify_to_list(int command, epee::levin::message_writer message, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections) final;
|
||||
virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections);
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::relay_method tx_relay);
|
||||
virtual bool invoke_notify_to_peer(int command, epee::levin::message_writer message, const epee::net_utils::connection_context_base& context) final;
|
||||
virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context);
|
||||
virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context);
|
||||
virtual bool drop_connection(const epee::net_utils::connection_context_base& context);
|
||||
virtual void request_callback(const epee::net_utils::connection_context_base& context);
|
||||
virtual void for_each_connection(std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
|
||||
|
|
|
@ -2175,9 +2175,8 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::relay_notify_to_list(int command, epee::levin::message_writer data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)
|
||||
bool node_server<t_payload_net_handler>::relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)
|
||||
{
|
||||
epee::byte_slice message = data_buff.finalize_notify(command);
|
||||
std::sort(connections.begin(), connections.end());
|
||||
auto zone = m_network_zones.begin();
|
||||
for(const auto& c_id: connections)
|
||||
|
@ -2195,7 +2194,7 @@ namespace nodetool
|
|||
++zone;
|
||||
}
|
||||
if (zone->first == c_id.first)
|
||||
zone->second.m_net_server.get_config_object().send(message.clone(), c_id.second);
|
||||
zone->second.m_net_server.get_config_object().notify(command, data_buff, c_id.second);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2262,13 +2261,24 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::invoke_notify_to_peer(const int command, epee::levin::message_writer message, const epee::net_utils::connection_context_base& context)
|
||||
bool node_server<t_payload_net_handler>::invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context)
|
||||
{
|
||||
if(is_filtered_command(context.m_remote_address, command))
|
||||
return false;
|
||||
|
||||
network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
|
||||
int res = zone.m_net_server.get_config_object().send(message.finalize_notify(command), context.m_connection_id);
|
||||
int res = zone.m_net_server.get_config_object().notify(command, req_buff, context.m_connection_id);
|
||||
return res > 0;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context)
|
||||
{
|
||||
if(is_filtered_command(context.m_remote_address, command))
|
||||
return false;
|
||||
|
||||
network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
|
||||
int res = zone.m_net_server.get_config_object().invoke(command, req_buff, resp_buff, context.m_connection_id);
|
||||
return res > 0;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#include "net/net_utils_base.h"
|
||||
#include "p2p_protocol_defs.h"
|
||||
|
||||
namespace epee { namespace levin { class message_writer; } }
|
||||
|
||||
namespace nodetool
|
||||
{
|
||||
|
||||
|
@ -51,9 +49,10 @@ namespace nodetool
|
|||
template<class t_connection_context>
|
||||
struct i_p2p_endpoint
|
||||
{
|
||||
virtual bool relay_notify_to_list(int command, epee::levin::message_writer message, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)=0;
|
||||
virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)=0;
|
||||
virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::relay_method tx_relay)=0;
|
||||
virtual bool invoke_notify_to_peer(int command, epee::levin::message_writer message, const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual bool drop_connection(const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual void request_callback(const epee::net_utils::connection_context_base& context)=0;
|
||||
virtual uint64_t get_public_connections_count()=0;
|
||||
|
@ -72,7 +71,7 @@ namespace nodetool
|
|||
template<class t_connection_context>
|
||||
struct p2p_endpoint_stub: public i_p2p_endpoint<t_connection_context>
|
||||
{
|
||||
virtual bool relay_notify_to_list(int command, epee::levin::message_writer message, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)
|
||||
virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -80,7 +79,11 @@ namespace nodetool
|
|||
{
|
||||
return epee::net_utils::zone::invalid;
|
||||
}
|
||||
virtual bool invoke_notify_to_peer(int command, epee::levin::message_writer message, const epee::net_utils::connection_context_base& context)
|
||||
virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue