From 745b6ba46c7b6c9d3f06fc604231c9f9f0e31a31 Mon Sep 17 00:00:00 2001 From: Alexander Suprunenko Date: Thu, 20 Jun 2019 01:52:43 +0300 Subject: [PATCH] relating to announce removed --- src/p2p/net_node.h | 119 --------- src/p2p/net_node.inl | 310 ------------------------ src/p2p/p2p_protocol_defs.h | 35 --- src/rpc/core_rpc_server.cpp | 31 --- src/rpc/core_rpc_server.h | 4 - src/rpc/core_rpc_server_commands_defs.h | 56 ----- 6 files changed, 555 deletions(-) diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index d6c020d4e..c5bc873a3 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -92,27 +92,6 @@ namespace nodetool bool m_in_timedsync; }; - struct local_supernode { - local_supernode(std::string host, uint64_t port, std::string uri) : http_host(std::move(host)), http_port(port), uri(std::move(uri)) { - client.set_server(http_host, std::to_string(http_port), {}); - } - - void update(const std::string &new_host, uint64_t new_port, const std::string &new_uri) { - if (new_host != http_host || new_port != http_port) { - if (client.is_connected()) client.disconnect(); - client.set_server(new_host, std::to_string(new_port), {}); - http_host = new_host; - http_port = new_port; - uri = new_uri; - } - } - - std::string http_host; - uint64_t http_port; - std::string uri; - epee::net_utils::http::http_simple_client client; - }; - template class node_server: public epee::levin::levin_commands_handler >, public i_p2p_endpoint, @@ -180,19 +159,12 @@ namespace nodetool // Graft/RTA methods to be called from RPC handlers - /*! - * \brief do_supernode_announce - posts supernode announce to p2p network - * \param req - */ - void do_supernode_announce(const cryptonote::COMMAND_RPC_SUPERNODE_ANNOUNCE::request &req); /*! * \brief do_broadcast - posts broadcast message to p2p network * \param req */ void do_broadcast(const cryptonote::COMMAND_RPC_BROADCAST::request &req, uint64_t hop = 0); - std::vector get_tunnels() const; - private: const std::vector m_seed_nodes_list = { @@ -207,7 +179,6 @@ namespace nodetool CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context); //move levin_commands_handler interface notify(...) callbacks into nothing BEGIN_INVOKE_MAP2(node_server) - HANDLE_NOTIFY_T2(COMMAND_SUPERNODE_ANNOUNCE, &node_server::handle_supernode_announce) HANDLE_NOTIFY_T2(COMMAND_BROADCAST, &node_server::handle_broadcast) HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, &node_server::handle_handshake) @@ -225,8 +196,6 @@ namespace nodetool enum PeerType { anchor = 0, white, gray }; //----------------- helper functions ------------------------------------------------ - uint64_t get_max_hop(const std::list &addresses); - std::list get_routes(); // sometimes supernode gets very busy so it doesn't respond within 1 second, increasing timeout to 3s static constexpr size_t SUPERNODE_HTTP_TIMEOUT_MILLIS = 3 * 1000; @@ -257,33 +226,6 @@ namespace nodetool return 1; } - template - int post_request_to_supernode(local_supernode &supernode, const std::string &method, const typename request_struct::request &body, - const std::string &endpoint = std::string()) - { - boost::value_initialized > init_req; - epee::json_rpc::request& req = static_cast &>(init_req); - req.jsonrpc = "2.0"; - req.id = 0; - req.method = method; - req.params = body; - - std::string uri = "/" + method; - if (!endpoint.empty()) - { - uri = endpoint; - } - typename request_struct::response resp = AUTO_VAL_INIT(resp); - bool r = epee::net_utils::invoke_http_json(supernode.uri + uri, - req, resp, supernode.client, - std::chrono::milliseconds(size_t(SUPERNODE_HTTP_TIMEOUT_MILLIS)), "POST"); - if (!r || resp.status == 0) - { - return 0; - } - return 1; - } - template int post_request_to_supernodes(const std::string &method, const typename request_struct::request &body, const std::string &endpoint = std::string()) @@ -321,7 +263,6 @@ namespace nodetool void remove_old_request_cache(); //----------------- commands handlers ---------------------------------------------- - int handle_supernode_announce(int command, typename COMMAND_SUPERNODE_ANNOUNCE::request& arg, p2p_connection_context& context); int handle_broadcast(int command, typename COMMAND_BROADCAST::request &arg, p2p_connection_context &context); int handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context); int handle_timed_sync(int command, typename COMMAND_TIMED_SYNC::request& arg, typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context); @@ -458,45 +399,6 @@ namespace nodetool epee::net_utils::connection_basic::set_save_graph(save_graph); } - void add_supernode(const std::string& addr, const std::string& url) - { - epee::net_utils::http::url_content parsed{}; - bool ret = epee::net_utils::parse_url(url, parsed); - boost::lock_guard guard(m_supernode_lock); - auto it = m_supernodes.find(addr); - if (!ret) { - if (it != m_supernodes.end()) m_supernodes.erase(it); - } else if (it == m_supernodes.end()) { - LOG_PRINT_L0("Adding supernode " << addr << " at " << parsed.host << ":" << parsed.port); - m_supernodes.emplace(std::piecewise_construct, - std::forward_as_tuple(addr), - std::forward_as_tuple(std::move(parsed.host), parsed.port, std::move(parsed.uri))); - } else { - it->second.update(parsed.host, parsed.port, parsed.uri); - } - } - - std::vector get_supernodes_addresses() { - boost::lock_guard guard(m_supernode_lock); - std::vector addrs; - addrs.reserve(m_supernodes.size()); - for (auto &sn : m_supernodes) { - addrs.push_back(sn.first); - } - return addrs; - } - - std::string join_supernodes_addresses(const std::string &joiner = " ") { - std::ostringstream s; - bool first = true; - for (auto &addr : get_supernodes_addresses()) { - if (first) first = false; - else s << joiner; - s << addr; - } - return s.str(); - } - template std::string join(const C& c, const std::string &joiner = " ") { std::ostringstream s; @@ -509,27 +411,13 @@ namespace nodetool return s.str(); } - bool remove_supernode(const std::string &addr) { - boost::lock_guard guard(m_supernode_lock); - return m_supernodes.erase(addr); - } - - void reset_supernodes() { - boost::lock_guard guard(m_supernode_lock); - m_supernodes.clear(); - } - bool notify_peer_list(int command, const std::string& buf, const std::vector& peers_to_send, bool try_connect = false); void send_stakes_to_supernode(); void send_blockchain_based_list_to_supernode(uint64_t last_received_block_height); - uint64_t get_announce_bytes_in() const { return m_announce_bytes_in; } - uint64_t get_announce_bytes_out() const { return m_announce_bytes_out; } uint64_t get_broadcast_bytes_in() const { return m_broadcast_bytes_in; } uint64_t get_broadcast_bytes_out() const { return m_broadcast_bytes_out; } - uint64_t get_multicast_bytes_in() const { return m_multicast_bytes_in; } - uint64_t get_multicast_bytes_out() const { return m_multicast_bytes_out; } //returns empty if sn is not found or dead sn_id_t check_supernode_id(const sn_id_t& local_sn) @@ -614,9 +502,6 @@ namespace nodetool private: std::multimap m_supernode_requests_timestamps; std::set m_supernode_requests_cache; - std::map m_supernode_routes; - std::unordered_map m_supernodes; - boost::recursive_mutex m_supernode_lock; boost::recursive_mutex m_request_cache_lock; std::vector m_custom_seed_nodes; @@ -676,12 +561,8 @@ namespace nodetool cryptonote::network_type m_nettype; // traffic counters - std::atomic m_announce_bytes_in {0}; - std::atomic m_announce_bytes_out {0}; std::atomic m_broadcast_bytes_in {0}; std::atomic m_broadcast_bytes_out {0}; - std::atomic m_multicast_bytes_in {0}; - std::atomic m_multicast_bytes_out {0}; }; const int64_t default_limit_up = 2048; // kB/s diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 986e49cd8..7707b1f7a 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -883,52 +883,6 @@ namespace nodetool return true; } - //----------------------------------------------------------------------------------- - template - uint64_t node_server::get_max_hop(const std::list &addresses) - { - uint64_t max_hop = 0; - { - std::map local_supernode_routes; - { - MDEBUG("P2P Request: multicast_send: lock"); - boost::lock_guard guard(m_supernode_lock); - MDEBUG("P2P Request: multicast_send: unlock"); - local_supernode_routes = m_supernode_routes; - } - for (auto addr : addresses) - { - auto it = local_supernode_routes.find(addr); - if (it != local_supernode_routes.end() && max_hop < (*it).second.max_hop) - { - max_hop = (*it).second.max_hop; - } - } - } - return max_hop; - } - - //----------------------------------------------------------------------------------- - template - std::list node_server::get_routes() - { - std::list routes; - { - std::map local_supernode_routes; - { - MDEBUG("P2P Request: multicast_send: lock"); - boost::lock_guard guard(m_supernode_lock); - MDEBUG("P2P Request: multicast_send: unlock"); - local_supernode_routes = m_supernode_routes; - } - for (auto it = local_supernode_routes.begin(); it != local_supernode_routes.end(); ++it) - { - routes.push_back((*it).first); - } - } - return routes; - } - //----------------------------------------------------------------------------------- template void node_server::remove_old_request_cache() @@ -948,155 +902,6 @@ namespace nodetool } } - //----------------------------------------------------------------------------------- - template - int node_server::handle_supernode_announce(int command, COMMAND_SUPERNODE_ANNOUNCE::request& arg, p2p_connection_context& context) - { - MDEBUG("P2P Request: handle_supernode_announce: start"); - - m_announce_bytes_in += get_command_size(arg); - - if (context.m_state != p2p_connection_context::state_normal) { - MWARNING(context << " invalid connection (no handshake)"); - return 1; - } - -#ifdef LOCK_RTA_SENDING - return 1; -#endif - static std::string supernode_endpoint("send_supernode_announce"); - std::string supernode_str = arg.supernode_public_id; - - bool is_local; - { - boost::lock_guard guard(m_supernode_lock); - is_local = m_supernodes.count(supernode_str) > 0; - } - if (!is_local) { - MDEBUG("P2P Request: handle_supernode_announce: update tunnels for " << arg.supernode_public_id << " Hop: " << arg.hop << " Address: " << arg.network_address); - - peerlist_entry pe; - // TODO: Need to investigate it and mechanism for adding peer to the peerlist - if (!m_peerlist.find_peer(context.peer_id, pe)) - { // unknown peer, alternative handshake with it - MDEBUG("unknown peer, alternative handshake with it " << context.peer_id); - return 1; - } - { - MDEBUG("P2P Request: handle_supernode_announce: lock"); - boost::lock_guard guard(m_request_cache_lock); - MDEBUG("P2P Request: handle_supernode_announce: unlock"); - remove_old_request_cache(); - } - MDEBUG("P2P Request: handle_supernode_announce: lock"); - boost::lock_guard guard(m_supernode_lock); - MDEBUG("P2P Request: handle_supernode_announce: unlock"); - - MDEBUG("P2P Request: handle_supernode_announce: routes number - " << m_supernode_routes.size()); - for (auto it2 = m_supernode_routes.begin(); it2 != m_supernode_routes.end(); ++it2) - { - MDEBUG("P2P Request: handle_supernode_announce: " << (*it2).first << " " << (*it2).second.peers.size()); - } - - - auto it = m_supernode_routes.find(supernode_str); - if (it == m_supernode_routes.end()) - { - std::vector peer_vec; - peer_vec.push_back(pe); - nodetool::supernode_route route; - route.last_announce_height = arg.height; - route.last_announce_time = time(nullptr); - route.max_hop = arg.hop; - route.peers = peer_vec; - m_supernode_routes[supernode_str] = route; - } - else { - auto &route = it->second; -#if 0 - // this check is not correct in case stake transactions if older tx has greater lock time than newer one - if (route.last_announce_height > arg.height) - { - MINFO("SUPERNODE_ANNOUNCE from " << context.peer_id - << " too old, corrent route height " << (*it).second.last_announce_height); - return 1; - } -#endif - - if (route.last_announce_height == arg.height && route.last_announce_time + DIFFICULTY_TARGET_V2 > (unsigned)time(nullptr)) - { - MDEBUG("existing announce, height: " << arg.height << ", last_announce_time: " << (*it).second.last_announce_time - << ", current time: " << time(nullptr)); - auto peer_it = std::find_if(route.peers.begin(), route.peers.end(), - [pe](const peerlist_entry &p) -> bool { return pe.id == p.id; }); - if (peer_it == route.peers.end()) - { - route.peers.push_back(pe); - if (route.max_hop < arg.hop) - { - route.max_hop = arg.hop; - } - } - return 1; - } - route.peers.clear(); - route.peers.push_back(pe); - route.last_announce_height = arg.height; - route.last_announce_time = time(nullptr); - route.max_hop = arg.hop; - } - } - - std::list> post_to_sn; - { - LOG_PRINT_L3("P2P Request: handle_supernode_announce: lock"); - boost::lock_guard guard(m_supernode_lock); - LOG_PRINT_L3("P2P Request: handle_supernode_announce: unlock"); - for (auto &sn : m_supernodes) { - if (sn.first != supernode_str) - post_to_sn.push_back(std::ref(sn.second)); - } - } - for (auto &sn : post_to_sn) { - LOG_PRINT_L1("P2P Request: handle_supernode_announce: post to supernode"); - post_request_to_supernode(sn, supernode_endpoint, arg); - } - - if (!is_local) { - // Notify neighbours about new ANNOUNCE - arg.hop++; - MDEBUG("P2P Request: handle_supernode_announce: notify peers " << arg.hop); - - std::list all_connections, random_connections; - m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) - { - // skip ourself connections - if(cntxt.peer_id == m_config.m_peer_id) - return true; - all_connections.push_back(cntxt.m_connection_id); - return true; - }); - - if (all_connections.empty()) { - MWARNING("P2P Request: no connections to relay announce"); - return 1; - } - - select_subset_with_probability(1.0 / all_connections.size(), all_connections, random_connections); - - std::string arg_buff; - epee::serialization::store_t_to_binary(arg, arg_buff); - - MDEBUG("P2P Request: handle_supernode_announce: relaying to neighbours: " << random_connections.size()); - - relay_notify_to_list(command, arg_buff, random_connections); - m_announce_bytes_out += arg_buff.size() * random_connections.size(); - } - - MDEBUG("P2P Request: handle_supernode_announce: end"); - return 1; - } - template int node_server::handle_broadcast(int command, typename COMMAND_BROADCAST::request &arg, p2p_connection_context &context) { @@ -2386,94 +2191,6 @@ namespace nodetool MINFO("Connections: \r\n" << connections); return true; } - //----------------------------------------------------------------------------------- - template - void node_server::do_supernode_announce(const cryptonote::COMMAND_RPC_SUPERNODE_ANNOUNCE::request &req) - { - MTRACE("Incoming supernode announce request"); -#ifdef LOCK_RTA_SENDING - return; -#endif - - MDEBUG("P2P Request: do_supernode_announce: start"); - - COMMAND_SUPERNODE_ANNOUNCE::request p2p_req; - p2p_req.supernode_public_id = req.supernode_public_id; - p2p_req.height = req.height; - p2p_req.signature = req.signature; - p2p_req.network_address = req.network_address; - p2p_req.hop = 0; - - MDEBUG("P2P Request: do_supernode_announce: announce to me"); - { - MDEBUG("P2P Request: do_supernode_announce: lock"); - boost::unique_lock guard(m_supernode_lock); - MDEBUG("P2P Request: do_supernode_announce: lock acquired"); - post_request_to_supernodes("send_supernode_announce", p2p_req); - } - - MDEBUG("P2P Request: do_supernode_announce: prepare peerlist"); - std::string blob; - epee::serialization::store_t_to_binary(p2p_req, blob); - std::set announced_peers; - - - // first collect all connections into container - // (its rarely possible connection could be erased from connection_map while iterating with 'foreach_connection') - std::list all_connections; - m_net_server.get_config_object().foreach_connection([&](p2p_connection_context& context) { - all_connections.push_back( - {context.m_connection_id, - context.peer_id, - epee::net_utils::print_connection_context_short(context)} ); - return true; - }); - - std::list random_connections; - - select_subset_with_probability(1.0 /*/ all_connections.size()*/, all_connections, random_connections); - - - // same as 'relay_notify_to_list' does but we also need a) populate announced_peers and b) some extra logging - for (const auto &c: random_connections) { - MTRACE("[" << c.info << "] invoking COMMAND_SUPERNODE_ANNOUCE"); - if (m_net_server.get_config_object().notify(COMMAND_SUPERNODE_ANNOUNCE::ID, blob, c.id)) { - MTRACE("[" << c.info << "] COMMAND_SUPERNODE_ANNOUCE invoked, peer_id: " << c.peer_id); - announced_peers.insert(c.peer_id); - - - } - else - LOG_ERROR("[" << c.info << "] failed to invoke COMMAND_SUPERNODE_ANNOUNCE"); - } - m_announce_bytes_out += blob.size() * announced_peers.size(); - - return; - // XXX: not clear why do we need to send to "peers" if we already sent to all the connected neighbours? - // also, - - std::list peerlist_white, peerlist_gray; - m_peerlist.get_peerlist_full(peerlist_gray, peerlist_white); - std::vector peers_to_send; - for (auto pe :peerlist_white) { - if (announced_peers.find(pe.id) != announced_peers.end()) { - continue; - } - peers_to_send.push_back(pe); - } - if (peers_to_send.empty()) { - MWARNING("P2P Request: do_supernode_announce: peers_to_send is empty"); - return; - } - std::vector random_peers_to_send; - select_subset_with_probability(1.0 / peers_to_send.size(), peers_to_send, random_peers_to_send); - - MDEBUG("P2P Request: do_supernode_announce: peers_to_send size: " << random_peers_to_send.size() << ", peerlist_white size: " << peerlist_white.size() << ", announced_peers size: " << announced_peers.size()); - MDEBUG("P2P Request: do_supernode_announce: notify_peer_list"); - notify_peer_list(COMMAND_SUPERNODE_ANNOUNCE::ID, blob, random_peers_to_send); - MDEBUG("P2P Request: do_supernode_announce: end"); - } - //----------------------------------------------------------------------------------- template void node_server::do_broadcast(const cryptonote::COMMAND_RPC_BROADCAST::request &req, uint64_t hop) @@ -2570,33 +2287,6 @@ namespace nodetool MDEBUG("P2P Request: do_broadcast: End"); } - //----------------------------------------------------------------------------------- - template - std::vector node_server::get_tunnels() const - { - std::vector tunnels; - for (auto it = m_supernode_routes.begin(); it != m_supernode_routes.end(); ++it) - { - cryptonote::route_data route; - route.address = it->first; - route.last_announce_height = it->second.last_announce_height; - route.max_hop = it->second.max_hop; - std::vector peers; - for (auto pit = it->second.peers.begin(); pit != it->second.peers.end(); ++pit) - { - cryptonote::peer_data peer; - peer.host = pit->adr.host_str(); - peer.port = pit->adr.template as().port(); - peer.id = pit->id; - peer.last_seen = pit->last_seen; - peers.push_back(peer); - } - route.peers = peers; - tunnels.push_back(route); - } - return tunnels; - } - //----------------------------------------------------------------------------------- template std::string node_server::print_connections_container() diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 328ee2370..f8df48e1d 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -164,40 +164,11 @@ namespace nodetool END_KV_SERIALIZE_MAP() }; - struct supernode_route - { - crypto::public_key addr; - uint64_t last_announce_height; - uint64_t last_announce_time; - uint64_t max_hop; - std::vector peers; - }; - #define P2P_COMMANDS_POOL_BASE 1000 /************************************************************************/ /* */ /************************************************************************/ - struct COMMAND_SUPERNODE_ANNOUNCE - { - const static int ID = P2P_COMMANDS_POOL_BASE + 20; - - struct request : public cryptonote::COMMAND_RPC_SUPERNODE_ANNOUNCE::request - { - uint64_t hop; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(supernode_public_id) - KV_SERIALIZE(height) - KV_SERIALIZE(signature) - KV_SERIALIZE(network_address) - KV_SERIALIZE(hop) - END_KV_SERIALIZE_MAP() - }; - - struct response : public cryptonote::COMMAND_RPC_SUPERNODE_ANNOUNCE::response { }; - }; - struct COMMAND_BROADCAST { const static int ID = P2P_COMMANDS_POOL_BASE + 21; @@ -507,12 +478,6 @@ namespace nodetool /************************************************************************/ /* */ /************************************************************************/ - //TODO: Look unused - struct NOTIFY_SUPERNODE_ANNOUNCE - { - const static int ID = P2P_COMMANDS_POOL_BASE + 10; - struct request : public cryptonote::COMMAND_RPC_SUPERNODE_ANNOUNCE::request {}; - }; inline crypto::hash get_proof_of_trust_hash(const nodetool::proof_of_trust& pot) { diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 0449a8e29..55e7de9ce 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2201,24 +2201,11 @@ namespace cryptonote return true; } - //------------------------------------------------------------------------------------------------------------------------------ - bool core_rpc_server::on_supernode_announce(const COMMAND_RPC_SUPERNODE_ANNOUNCE::request &req, COMMAND_RPC_SUPERNODE_ANNOUNCE::response &res, json_rpc::error &error_resp) - { - LOG_PRINT_L0("RPC Request: on_supernode_announce: start"); - // send p2p announce - m_p2p.add_supernode(req.supernode_public_id, req.network_address); - m_p2p.do_supernode_announce(req); - res.status = 0; - LOG_PRINT_L0("RPC Request: on_supernode_announce: end"); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_supernode_stakes(const COMMAND_RPC_SUPERNODE_GET_STAKES::request &req, COMMAND_RPC_SUPERNODE_GET_STAKES::response &res, json_rpc::error &error_resp) { LOG_PRINT_L0("RPC Request: on_supernode_stakes: start"); // send p2p stakes - m_p2p.add_supernode(req.supernode_public_id, req.network_address); m_p2p.send_stakes_to_supernode(); res.status = 0; LOG_PRINT_L0("RPC Request: on_supernode_stakes: end"); @@ -2230,7 +2217,6 @@ namespace cryptonote { LOG_PRINT_L0("RPC Request: on_supernode_blockchain_based_list: start"); // send p2p stake txs - m_p2p.add_supernode(req.supernode_public_id, req.network_address); m_p2p.send_blockchain_based_list_to_supernode(req.last_received_block_height); res.status = 0; LOG_PRINT_L0("RPC Request: on_supernode_blockchain_based_list: end"); @@ -2326,29 +2312,12 @@ namespace cryptonote return true; } - //------------------------------------------------------------------------------------------------------------------------------ - bool core_rpc_server::on_get_tunnels(const COMMAND_RPC_TUNNEL_DATA::request &req, COMMAND_RPC_TUNNEL_DATA::response &res, json_rpc::error &error_resp) - { - LOG_PRINT_L0("RPC Request: on_get_tunnels: start"); - res.supernodes_addresses = m_p2p.get_supernodes_addresses(); - res.tunnels = m_p2p.get_tunnels(); - // Temporary backwards compatibility (remove me along with the supernode_address member): store the first SN - if (res.supernodes_addresses.size() > 0) - res.supernode_address = res.supernodes_addresses[0]; - LOG_PRINT_L0("RPC Request: on_get_tunnels: end"); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_rta_stats(const COMMAND_RPC_RTA_STATS::request &req, COMMAND_RPC_RTA_STATS::response &res, epee::json_rpc::error &error_resp) { - res.announce_bytes_in = m_p2p.get_announce_bytes_in(); - res.announce_bytes_out = m_p2p.get_announce_bytes_out(); res.broadcast_bytes_in = m_p2p.get_broadcast_bytes_in(); res.broadcast_bytes_out = m_p2p.get_broadcast_bytes_out(); - res.multicast_bytes_in = m_p2p.get_multicast_bytes_in(); - res.multicast_bytes_out = m_p2p.get_multicast_bytes_out(); return true; } diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 346fb1139..9856e2a0a 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -155,13 +155,11 @@ namespace cryptonote END_JSON_RPC_MAP() // Graft RTA handlers start here BEGIN_JSON_RPC_MAP("/json_rpc/rta") - MAP_JON_RPC_WE("send_supernode_announce",on_supernode_announce, COMMAND_RPC_SUPERNODE_ANNOUNCE) MAP_JON_RPC_WE("broadcast", on_broadcast, COMMAND_RPC_BROADCAST) MAP_JON_RPC_WE("wide_broadcast", on_wide_broadcast, COMMAND_RPC_BROADCAST) MAP_JON_RPC_WE("register_supernode", on_register_supernode, COMMAND_RPC_REGISTER_SUPERNODE) MAP_JON_RPC_WE("redirect_supernode_id", on_redirect_supernode_id, COMMAND_RPC_REDIRECT_SUPERNODE_ID) - MAP_JON_RPC_WE("get_tunnels", on_get_tunnels, COMMAND_RPC_TUNNEL_DATA) MAP_JON_RPC_WE("send_supernode_stakes", on_supernode_stakes, COMMAND_RPC_SUPERNODE_GET_STAKES) MAP_JON_RPC_WE("send_supernode_blockchain_based_list", on_supernode_blockchain_based_list, COMMAND_RPC_SUPERNODE_GET_BLOCKCHAIN_BASED_LIST) MAP_JON_RPC_WE("get_stats", on_get_rta_stats, COMMAND_RPC_RTA_STATS) @@ -229,7 +227,6 @@ namespace cryptonote bool on_get_output_distribution(const COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::request& req, COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::response& res, epee::json_rpc::error& error_resp); //----------------------- // RTA - bool on_supernode_announce(const COMMAND_RPC_SUPERNODE_ANNOUNCE::request& req, COMMAND_RPC_SUPERNODE_ANNOUNCE::response& res, epee::json_rpc::error& error_resp); bool on_supernode_stakes(const COMMAND_RPC_SUPERNODE_GET_STAKES::request& req, COMMAND_RPC_SUPERNODE_GET_STAKES::response& res, epee::json_rpc::error& error_resp); bool on_supernode_blockchain_based_list(const COMMAND_RPC_SUPERNODE_GET_BLOCKCHAIN_BASED_LIST::request& req, COMMAND_RPC_SUPERNODE_GET_BLOCKCHAIN_BASED_LIST::response& res, epee::json_rpc::error& error_resp); bool on_broadcast(const COMMAND_RPC_BROADCAST::request &req, COMMAND_RPC_BROADCAST::response &res, epee::json_rpc::error &error_resp, bool wide = false); @@ -237,7 +234,6 @@ namespace cryptonote bool on_register_supernode(const COMMAND_RPC_REGISTER_SUPERNODE::request& req, COMMAND_RPC_REGISTER_SUPERNODE::response& res, epee::json_rpc::error& error_resp); bool on_redirect_supernode_id(const COMMAND_RPC_REDIRECT_SUPERNODE_ID::request& req, COMMAND_RPC_REDIRECT_SUPERNODE_ID::response& res, epee::json_rpc::error& error_resp); - bool on_get_tunnels(const COMMAND_RPC_TUNNEL_DATA::request &req, COMMAND_RPC_TUNNEL_DATA::response &res, epee::json_rpc::error &error_resp); bool on_get_rta_stats(const COMMAND_RPC_RTA_STATS::request &req, COMMAND_RPC_RTA_STATS::response &res, epee::json_rpc::error &error_resp); private: diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 8122acb78..e1b80ac83 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -2354,33 +2354,6 @@ namespace cryptonote }; }; - struct COMMAND_RPC_SUPERNODE_ANNOUNCE - { - struct request - { - - std::string supernode_public_id; - uint64_t height; - std::string signature; - std::string network_address; - - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(supernode_public_id) - KV_SERIALIZE(height) - KV_SERIALIZE(signature) - KV_SERIALIZE(network_address) - END_KV_SERIALIZE_MAP() - }; - - struct response - { - int64_t status; - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(status) - END_KV_SERIALIZE_MAP() - }; - }; - struct COMMAND_RPC_REGISTER_SUPERNODE { struct request @@ -2514,27 +2487,6 @@ namespace cryptonote END_KV_SERIALIZE_MAP() }; - struct COMMAND_RPC_TUNNEL_DATA - { - struct request - { - BEGIN_KV_SERIALIZE_MAP() - END_KV_SERIALIZE_MAP() - }; - - struct response - { - std::string supernode_address; - std::vector tunnels; - std::vector supernodes_addresses; - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(supernode_address) - KV_SERIALIZE(tunnels) - KV_SERIALIZE(supernodes_addresses) - END_KV_SERIALIZE_MAP() - }; - }; - struct COMMAND_RPC_RTA_STATS { struct request @@ -2545,19 +2497,11 @@ namespace cryptonote struct response { - uint64_t announce_bytes_in; - uint64_t announce_bytes_out; uint64_t broadcast_bytes_in; uint64_t broadcast_bytes_out; - uint64_t multicast_bytes_in; - uint64_t multicast_bytes_out; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(announce_bytes_in) - KV_SERIALIZE(announce_bytes_out) KV_SERIALIZE(broadcast_bytes_in) KV_SERIALIZE(broadcast_bytes_out) - KV_SERIALIZE(multicast_bytes_in) - KV_SERIALIZE(multicast_bytes_out) END_KV_SERIALIZE_MAP() }; };