mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
Merge commit 'c038cc8b791ffb4bcd5f13e47de1ea98815059fe' into MergeUpstream3
This commit is contained in:
commit
d703d14d56
16 changed files with 45 additions and 298 deletions
2
external/easylogging++/easylogging++.h
vendored
2
external/easylogging++/easylogging++.h
vendored
|
@ -127,6 +127,8 @@
|
|||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
# define ELPP_OS_EMSCRIPTEN 1
|
||||
#else
|
||||
# define ELPP_OS_EMSCRIPTEN 0
|
||||
#endif
|
||||
#if (defined(__DragonFly__))
|
||||
# define ELPP_OS_DRAGONFLY 1
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
// Copyright (c) 2014-2019, The Monero Project
|
||||
//
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
|
@ -25,29 +25,32 @@
|
|||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#pragma once
|
||||
#include "serialization/keyvalue_serialization.h"
|
||||
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
struct core_stat_info
|
||||
{
|
||||
uint64_t tx_pool_size;
|
||||
uint64_t blockchain_height;
|
||||
uint64_t mining_speed;
|
||||
uint64_t alternative_blocks;
|
||||
std::string top_block_id_str;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_pool_size)
|
||||
KV_SERIALIZE(blockchain_height)
|
||||
KV_SERIALIZE(mining_speed)
|
||||
KV_SERIALIZE(alternative_blocks)
|
||||
KV_SERIALIZE(top_block_id_str)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
// This class is meant to create a batch when none currently exists.
|
||||
// If a batch exists, it can't be from another thread, since we can
|
||||
// only be called with the txpool lock taken, and it is held during
|
||||
// the whole prepare/handle/cleanup incoming block sequence.
|
||||
class LockedTXN {
|
||||
public:
|
||||
LockedTXN(Blockchain &b): m_db{b.get_db()} {
|
||||
m_batch = m_db.batch_start();
|
||||
}
|
||||
LockedTXN(const LockedTXN &) = delete;
|
||||
LockedTXN &operator=(const LockedTXN &) = delete;
|
||||
LockedTXN(LockedTXN &&o) : m_db{o.m_db}, m_batch{o.m_batch} { o.m_batch = false; }
|
||||
LockedTXN &operator=(LockedTXN &&) = delete;
|
||||
|
||||
void commit() { try { if (m_batch) { m_db.batch_stop(); m_batch = false; } } catch (const std::exception &e) { MWARNING("LockedTXN::commit filtering exception: " << e.what()); } }
|
||||
void abort() { try { if (m_batch) { m_db.batch_abort(); m_batch = false; } } catch (const std::exception &e) { MWARNING("LockedTXN::abort filtering exception: " << e.what()); } }
|
||||
~LockedTXN() { this->abort(); }
|
||||
private:
|
||||
BlockchainDB &m_db;
|
||||
bool m_batch;
|
||||
};
|
||||
}
|
|
@ -192,7 +192,6 @@ namespace config
|
|||
uint8_t const FEE_CALCULATION_MAX_RETRIES = 10;
|
||||
uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)2000000000); // 2 * pow(10, 9)
|
||||
uint64_t const BASE_REWARD_CLAMP_THRESHOLD = ((uint64_t)100000000); // pow(10, 8)
|
||||
std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 114;
|
||||
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 115;
|
||||
|
|
|
@ -1590,17 +1590,6 @@ namespace cryptonote
|
|||
{
|
||||
return quorumnet_send_blink(*this, tx_blob);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::get_stat_info(core_stat_info& st_inf) const
|
||||
{
|
||||
st_inf.mining_speed = m_miner.get_speed();
|
||||
st_inf.alternative_blocks = m_blockchain_storage.get_alternative_blocks_count();
|
||||
st_inf.blockchain_height = m_blockchain_storage.get_current_blockchain_height();
|
||||
st_inf.tx_pool_size = m_mempool.get_transactions_count();
|
||||
st_inf.top_block_id_str = epee::string_tools::pod_to_hex(m_blockchain_storage.get_tail_id());
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::check_tx_semantic(const transaction& tx, bool keeped_by_block) const
|
||||
{
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "service_node_quorum_cop.h"
|
||||
#include "cryptonote_basic/miner.h"
|
||||
#include "cryptonote_basic/connection_context.h"
|
||||
#include "cryptonote_basic/cryptonote_stat_info.h"
|
||||
#include "warnings.h"
|
||||
#include "crypto/hash.h"
|
||||
PUSH_WARNINGS
|
||||
|
@ -581,15 +580,6 @@ namespace cryptonote
|
|||
*/
|
||||
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const;
|
||||
|
||||
/**
|
||||
* @brief gets some stats about the daemon
|
||||
*
|
||||
* @param st_inf return-by-reference container for the stats requested
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
bool get_stat_info(core_stat_info& st_inf) const;
|
||||
|
||||
/**
|
||||
* @copydoc Blockchain::get_tx_outputs_gindexs
|
||||
*
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "cryptonote_core/service_node_list.h"
|
||||
#include "cryptonote_config.h"
|
||||
#include "blockchain.h"
|
||||
#include "blockchain_db/locked_txn.h"
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "common/boost_serialization_helper.h"
|
||||
#include "common/lock.h"
|
||||
|
@ -94,28 +95,6 @@ namespace cryptonote
|
|||
else
|
||||
return get_min_block_weight(version) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
|
||||
}
|
||||
|
||||
// This class is meant to create a batch when none currently exists.
|
||||
// If a batch exists, it can't be from another thread, since we can
|
||||
// only be called with the txpool lock taken, and it is held during
|
||||
// the whole prepare/handle/cleanup incoming block sequence.
|
||||
class LockedTXN {
|
||||
public:
|
||||
LockedTXN(Blockchain &b): m_db{b.get_db()} {
|
||||
m_batch = m_db.batch_start();
|
||||
}
|
||||
LockedTXN(const LockedTXN &) = delete;
|
||||
LockedTXN &operator=(const LockedTXN &) = delete;
|
||||
LockedTXN(LockedTXN &&o) : m_db{o.m_db}, m_batch{o.m_batch} { o.m_batch = false; }
|
||||
LockedTXN &operator=(LockedTXN &&) = delete;
|
||||
|
||||
void commit() { try { if (m_batch) { m_db.batch_stop(); m_batch = false; } } catch (const std::exception &e) { MWARNING("LockedTXN::commit filtering exception: " << e.what()); } }
|
||||
void abort() { try { if (m_batch) { m_db.batch_abort(); m_batch = false; } } catch (const std::exception &e) { MWARNING("LockedTXN::abort filtering exception: " << e.what()); } }
|
||||
~LockedTXN() { this->abort(); }
|
||||
private:
|
||||
BlockchainDB &m_db;
|
||||
bool m_batch;
|
||||
};
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
// warning: bchs is passed here uninitialized, so don't do anything but store it
|
||||
|
@ -417,7 +396,8 @@ namespace cryptonote
|
|||
memset(meta.padding, 0, sizeof(meta.padding));
|
||||
try
|
||||
{
|
||||
m_parsed_tx_cache.insert(std::make_pair(id, tx));
|
||||
if (opts.kept_by_block)
|
||||
m_parsed_tx_cache.insert(std::make_pair(id, tx));
|
||||
auto b_lock = tools::unique_lock(m_blockchain);
|
||||
LockedTXN lock(m_blockchain);
|
||||
m_blockchain.add_txpool_tx(id, blob, meta);
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "block_queue.h"
|
||||
#include "common/perf_timer.h"
|
||||
#include "cryptonote_basic/connection_context.h"
|
||||
#include "cryptonote_basic/cryptonote_stat_info.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
PUSH_WARNINGS
|
||||
|
@ -64,7 +63,6 @@ namespace cryptonote
|
|||
{
|
||||
public:
|
||||
typedef cryptonote_connection_context connection_context;
|
||||
typedef core_stat_info stat_info;
|
||||
typedef t_cryptonote_protocol_handler<t_core> cryptonote_protocol_handler;
|
||||
typedef CORE_SYNC_DATA payload_type;
|
||||
|
||||
|
@ -93,7 +91,6 @@ namespace cryptonote
|
|||
bool process_payload_sync_data(CORE_SYNC_DATA&& hshd, cryptonote_connection_context& context, bool is_inital);
|
||||
bool get_payload_sync_data(blobdata& data);
|
||||
bool get_payload_sync_data(CORE_SYNC_DATA& hshd);
|
||||
bool get_stat_info(core_stat_info& stat_inf);
|
||||
bool on_callback(cryptonote_connection_context& context);
|
||||
t_core& get_core(){return m_core;}
|
||||
bool is_synchronized(){return m_synchronized;}
|
||||
|
|
|
@ -197,12 +197,6 @@ namespace cryptonote
|
|||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
bool t_cryptonote_protocol_handler<t_core>::get_stat_info(core_stat_info& stat_inf)
|
||||
{
|
||||
return m_core.get_stat_info(stat_inf);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------
|
||||
template<class t_core>
|
||||
void t_cryptonote_protocol_handler<t_core>::log_connections()
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
|
|
@ -282,8 +282,6 @@ namespace nodetool
|
|||
bool islimitup=false;
|
||||
bool islimitdown=false;
|
||||
|
||||
typedef COMMAND_REQUEST_STAT_INFO_T<typename t_payload_net_handler::stat_info> COMMAND_REQUEST_STAT_INFO;
|
||||
|
||||
CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context); //move levin_commands_handler interface invoke(...) callbacks into invoke map
|
||||
CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context); //move levin_commands_handler interface notify(...) callbacks into nothing
|
||||
|
||||
|
@ -294,9 +292,6 @@ namespace nodetool
|
|||
HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, &node_server::handle_handshake)
|
||||
HANDLE_INVOKE_T2(COMMAND_TIMED_SYNC, &node_server::handle_timed_sync)
|
||||
HANDLE_INVOKE_T2(COMMAND_PING, &node_server::handle_ping)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_STAT_INFO, &node_server::handle_get_stat_info)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_NETWORK_STATE, &node_server::handle_get_network_state)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_PEER_ID, &node_server::handle_get_peer_id)
|
||||
HANDLE_INVOKE_T2(COMMAND_REQUEST_SUPPORT_FLAGS, &node_server::handle_get_support_flags)
|
||||
CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(m_payload_handler, typename t_payload_net_handler::connection_context&)
|
||||
END_INVOKE_MAP2()
|
||||
|
@ -307,15 +302,11 @@ namespace nodetool
|
|||
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);
|
||||
int handle_ping(int command, COMMAND_PING::request& arg, COMMAND_PING::response& rsp, p2p_connection_context& context);
|
||||
int handle_get_stat_info(int command, typename COMMAND_REQUEST_STAT_INFO::request& arg, typename COMMAND_REQUEST_STAT_INFO::response& rsp, p2p_connection_context& context);
|
||||
int handle_get_network_state(int command, COMMAND_REQUEST_NETWORK_STATE::request& arg, COMMAND_REQUEST_NETWORK_STATE::response& rsp, p2p_connection_context& context);
|
||||
int handle_get_peer_id(int command, COMMAND_REQUEST_PEER_ID::request& arg, COMMAND_REQUEST_PEER_ID::response& rsp, p2p_connection_context& context);
|
||||
int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context);
|
||||
bool init_config();
|
||||
bool make_default_peer_id();
|
||||
bool make_default_config();
|
||||
bool store_config();
|
||||
bool check_trust(const proof_of_trust& tr, epee::net_utils::zone zone_type);
|
||||
|
||||
|
||||
//----------------- levin_commands_handler -------------------------------------------------------------
|
||||
|
@ -391,7 +382,6 @@ namespace nodetool
|
|||
bool set_rate_limit(const boost::program_options::variables_map& vm, int64_t limit);
|
||||
|
||||
bool has_too_many_connections(const epee::net_utils::network_address &address);
|
||||
uint64_t get_connections_count();
|
||||
size_t get_incoming_connections_count();
|
||||
size_t get_incoming_connections_count(network_zone&);
|
||||
size_t get_outgoing_connections_count();
|
||||
|
@ -454,7 +444,6 @@ namespace nodetool
|
|||
tools::periodic_task m_gray_peerlist_housekeeping_interval{1min};
|
||||
tools::periodic_task m_incoming_connections_interval{1h};
|
||||
|
||||
uint64_t m_last_stat_request_time;
|
||||
std::list<epee::net_utils::network_address> m_priority_peers;
|
||||
std::vector<epee::net_utils::network_address> m_exclusive_peers;
|
||||
std::vector<epee::net_utils::network_address> m_seed_nodes;
|
||||
|
|
|
@ -806,7 +806,6 @@ namespace nodetool
|
|||
|
||||
//only in case if we really sure that we have external visible ip
|
||||
m_have_address = true;
|
||||
m_last_stat_request_time = 0;
|
||||
|
||||
//configure self
|
||||
|
||||
|
@ -936,15 +935,6 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
uint64_t node_server<t_payload_net_handler>::get_connections_count()
|
||||
{
|
||||
std::uint64_t count = 0;
|
||||
for (auto& zone : m_network_zones)
|
||||
count += zone.second.m_net_server.get_config_object().get_connections_count();
|
||||
return count;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::deinit()
|
||||
{
|
||||
kill();
|
||||
|
@ -1428,10 +1418,10 @@ namespace nodetool
|
|||
|
||||
std::deque<size_t> filtered;
|
||||
const size_t limit = use_white_list ? 20 : std::numeric_limits<size_t>::max();
|
||||
size_t idx = 0, skipped = 0;
|
||||
for (int step = 0; step < 2; ++step)
|
||||
{
|
||||
bool skip_duplicate_class_B = step == 0 && m_nettype == cryptonote::MAINNET;
|
||||
size_t idx = 0, skipped = 0;
|
||||
zone.m_peerlist.foreach (use_white_list, [&classB, &filtered, &idx, &skipped, skip_duplicate_class_B, limit, next_needed_pruning_stripe](const peerlist_entry &pe){
|
||||
if (filtered.size() >= limit)
|
||||
return false;
|
||||
|
@ -1537,6 +1527,7 @@ namespace nodetool
|
|||
return true;
|
||||
|
||||
size_t try_count = 0;
|
||||
bool is_connected_to_at_least_one_seed_node = false;
|
||||
size_t current_index = crypto::rand_idx(m_seed_nodes.size());
|
||||
const net_server& server = m_network_zones.at(epee::net_utils::zone::public_).m_net_server;
|
||||
while(true)
|
||||
|
@ -1544,7 +1535,11 @@ namespace nodetool
|
|||
if(server.is_stop_signal_sent())
|
||||
return false;
|
||||
|
||||
if(try_to_connect_and_handshake_with_new_peer(m_seed_nodes[current_index], true))
|
||||
peerlist_entry pe_seed{};
|
||||
pe_seed.adr = m_seed_nodes[current_index];
|
||||
if (is_peer_used(pe_seed))
|
||||
is_connected_to_at_least_one_seed_node = true;
|
||||
else if (try_to_connect_and_handshake_with_new_peer(m_seed_nodes[current_index], true))
|
||||
break;
|
||||
if(++try_count > m_seed_nodes.size())
|
||||
{
|
||||
|
@ -1567,7 +1562,8 @@ namespace nodetool
|
|||
}
|
||||
else
|
||||
{
|
||||
MWARNING("Failed to connect to any of seed peers, continuing without seeds");
|
||||
if (!is_connected_to_at_least_one_seed_node)
|
||||
MWARNING("Failed to connect to any of seed peers, continuing without seeds");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1928,88 +1924,6 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::check_trust(const proof_of_trust& tr, const epee::net_utils::zone zone_type)
|
||||
{
|
||||
uint64_t local_time = time(NULL);
|
||||
uint64_t time_delata = local_time > tr.time ? local_time - tr.time: tr.time - local_time;
|
||||
if(time_delata > 24*60*60 )
|
||||
{
|
||||
MWARNING("check_trust failed to check time conditions, local_time=" << local_time << ", proof_time=" << tr.time);
|
||||
return false;
|
||||
}
|
||||
if(m_last_stat_request_time >= tr.time )
|
||||
{
|
||||
MWARNING("check_trust failed to check time conditions, last_stat_request_time=" << m_last_stat_request_time << ", proof_time=" << tr.time);
|
||||
return false;
|
||||
}
|
||||
|
||||
const network_zone& zone = m_network_zones.at(zone_type);
|
||||
if(zone.m_config.m_peer_id != tr.peer_id)
|
||||
{
|
||||
MWARNING("check_trust failed: peer_id mismatch (passed " << tr.peer_id << ", expected " << peerid_to_string(zone.m_config.m_peer_id) << ")");
|
||||
return false;
|
||||
}
|
||||
crypto::public_key pk{};
|
||||
epee::string_tools::hex_to_pod(::config::P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY, pk);
|
||||
crypto::hash h = get_proof_of_trust_hash(tr);
|
||||
if(!crypto::check_signature(h, pk, tr.sign))
|
||||
{
|
||||
MWARNING("check_trust failed: sign check failed");
|
||||
return false;
|
||||
}
|
||||
//update last request time
|
||||
m_last_stat_request_time = tr.time;
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
int node_server<t_payload_net_handler>::handle_get_stat_info(int command, typename COMMAND_REQUEST_STAT_INFO::request& arg, typename COMMAND_REQUEST_STAT_INFO::response& rsp, p2p_connection_context& context)
|
||||
{
|
||||
if(!check_trust(arg.tr, context.m_remote_address.get_zone()))
|
||||
{
|
||||
drop_connection(context);
|
||||
return 1;
|
||||
}
|
||||
rsp.connections_count = get_connections_count();
|
||||
rsp.incoming_connections_count = rsp.connections_count - get_outgoing_connections_count();
|
||||
rsp.version = LOKI_VERSION_FULL;
|
||||
m_payload_handler.get_stat_info(rsp.payload_info);
|
||||
return 1;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
int node_server<t_payload_net_handler>::handle_get_network_state(int command, COMMAND_REQUEST_NETWORK_STATE::request& arg, COMMAND_REQUEST_NETWORK_STATE::response& rsp, p2p_connection_context& context)
|
||||
{
|
||||
if(!check_trust(arg.tr, context.m_remote_address.get_zone()))
|
||||
{
|
||||
drop_connection(context);
|
||||
return 1;
|
||||
}
|
||||
m_network_zones.at(epee::net_utils::zone::public_).m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
|
||||
{
|
||||
connection_entry ce;
|
||||
ce.adr = cntxt.m_remote_address;
|
||||
ce.id = cntxt.peer_id;
|
||||
ce.is_income = cntxt.m_is_income;
|
||||
rsp.connections_list.push_back(ce);
|
||||
return true;
|
||||
});
|
||||
|
||||
network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
|
||||
zone.m_peerlist.get_peerlist(rsp.local_peerlist_gray, rsp.local_peerlist_white);
|
||||
rsp.my_id = zone.m_config.m_peer_id;
|
||||
rsp.local_time = time(NULL);
|
||||
return 1;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
int node_server<t_payload_net_handler>::handle_get_peer_id(int command, COMMAND_REQUEST_PEER_ID::request& arg, COMMAND_REQUEST_PEER_ID::response& rsp, p2p_connection_context& context)
|
||||
{
|
||||
rsp.my_id = m_network_zones.at(context.m_remote_address.get_zone()).m_config.m_peer_id;
|
||||
return 1;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
int node_server<t_payload_net_handler>::handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context)
|
||||
{
|
||||
rsp.support_flags = m_network_zones.at(context.m_remote_address.get_zone()).m_config.m_support_flags;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
#include "cryptonote_config.h"
|
||||
#include "net/enums.h"
|
||||
#include "net/local_ip.h"
|
||||
|
|
|
@ -274,107 +274,6 @@ namespace nodetool
|
|||
};
|
||||
|
||||
|
||||
struct proof_of_trust
|
||||
{
|
||||
peerid_type peer_id;
|
||||
uint64_t time;
|
||||
crypto::signature sign;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(peer_id)
|
||||
KV_SERIALIZE(time)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
template<class payload_stat_info>
|
||||
struct COMMAND_REQUEST_STAT_INFO_T
|
||||
{
|
||||
const static int ID = P2P_COMMANDS_POOL_BASE + 4;
|
||||
|
||||
struct request
|
||||
{
|
||||
proof_of_trust tr;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tr)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string version;
|
||||
std::string os_version;
|
||||
uint64_t connections_count;
|
||||
uint64_t incoming_connections_count;
|
||||
payload_stat_info payload_info;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(version)
|
||||
KV_SERIALIZE(os_version)
|
||||
KV_SERIALIZE(connections_count)
|
||||
KV_SERIALIZE(incoming_connections_count)
|
||||
KV_SERIALIZE(payload_info)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
struct COMMAND_REQUEST_NETWORK_STATE
|
||||
{
|
||||
const static int ID = P2P_COMMANDS_POOL_BASE + 5;
|
||||
|
||||
struct request
|
||||
{
|
||||
proof_of_trust tr;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tr)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
std::vector<peerlist_entry> local_peerlist_white;
|
||||
std::vector<peerlist_entry> local_peerlist_gray;
|
||||
std::vector<connection_entry> connections_list;
|
||||
peerid_type my_id;
|
||||
uint64_t local_time;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_white)
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_gray)
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(connections_list)
|
||||
KV_SERIALIZE(my_id)
|
||||
KV_SERIALIZE(local_time)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
struct COMMAND_REQUEST_PEER_ID
|
||||
{
|
||||
const static int ID = P2P_COMMANDS_POOL_BASE + 6;
|
||||
|
||||
struct request
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
peerid_type my_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(my_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
@ -397,14 +296,4 @@ namespace nodetool
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
inline crypto::hash get_proof_of_trust_hash(const nodetool::proof_of_trust& pot)
|
||||
{
|
||||
std::string s;
|
||||
s.append(reinterpret_cast<const char*>(&pot.peer_id), sizeof(pot.peer_id));
|
||||
s.append(reinterpret_cast<const char*>(&pot.time), sizeof(pot.time));
|
||||
return crypto::cn_fast_hash(s.data(), s.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ namespace tests
|
|||
bool init(const boost::program_options::variables_map& vm);
|
||||
bool deinit(){return true;}
|
||||
bool get_short_chain_history(std::list<crypto::hash>& ids);
|
||||
bool get_stat_info(cryptonote::core_stat_info& st_inf){return true;}
|
||||
bool have_block(const crypto::hash& id);
|
||||
void get_blockchain_top(uint64_t& height, crypto::hash& top_id);
|
||||
bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, const cryptonote::tx_pool_options &opts);
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "boost/archive/portable_binary_iarchive.hpp"
|
||||
#include "boost/archive/portable_binary_oarchive.hpp"
|
||||
#include "byte_slice.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "hex.h"
|
||||
#include "net/net_utils_base.h"
|
||||
#include "net/local_ip.h"
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
#include "net/dandelionpp.h"
|
||||
#include "net/error.h"
|
||||
#include "net/net_utils_base.h"
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
bool init(const boost::program_options::variables_map& vm) {return true ;}
|
||||
bool deinit(){return true;}
|
||||
bool get_short_chain_history(std::list<crypto::hash>& ids) const { return true; }
|
||||
bool get_stat_info(cryptonote::core_stat_info& st_inf) const {return true;}
|
||||
bool have_block(const crypto::hash& id) const {return true;}
|
||||
void get_blockchain_top(uint64_t& height, crypto::hash& top_id)const{height=0;top_id=crypto::null_hash;}
|
||||
std::vector<cryptonote::core::tx_verification_batch_info> parse_incoming_txs(const std::vector<cryptonote::blobdata>& tx_blobs, const cryptonote::tx_pool_options &opts) { return {}; }
|
||||
|
|
Loading…
Reference in a new issue