37 #include <boost/program_options/variables_map.hpp>
40 #include "math_helper.h"
41 #include "storages/levin_abstract_invoke2.h"
48 #include <boost/circular_buffer.hpp>
53 #define LOCALHOST_INT 2130706433
54 #define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT 100
60 class cryptonote_protocol_handler_base_pimpl;
63 std::unique_ptr<cryptonote_protocol_handler_base_pimpl>
mI;
75 template<class t_core>
86 HANDLE_NOTIFY_T2(
NOTIFY_NEW_BLOCK, &cryptonote_protocol_handler::handle_notify_new_block)
103 bool get_payload_sync_data(
blobdata& data);
106 t_core& get_core(){
return m_core;}
108 void log_connections();
109 std::list<connection_info> get_connections();
116 std::string get_peers_overview()
const;
117 std::pair<uint32_t, uint32_t> get_next_needed_pruning_stripe()
const;
118 bool needs_new_sync_connections()
const;
119 bool is_busy_syncing();
140 size_t get_synchronizing_connections_count();
141 bool on_connection_synchronized();
146 void drop_connections(
const epee::net_utils::network_address address);
147 bool kick_idle_peers();
148 bool check_standby_peers();
149 bool update_sync_search();
184 uint64_t get_estimated_remaining_sync_seconds(uint64_t current_blockchain_height, uint64_t target_blockchain_height);
185 std::string get_periodic_sync_estimate(uint64_t current_blockchain_height, uint64_t target_blockchain_height);
189 boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
193 template<
class t_parameter>
196 LOG_PRINT_L2(
"[" << epee::net_utils::print_connection_context_short(
context) <<
"] post " <<
typeid(t_parameter).
name() <<
" -->");
198 epee::serialization::store_t_to_binary(arg, blob);
static void init(std::string cache_filename)
Definition: blockchain_blackball.cpp:221
Definition: block_queue.h:49
Definition: cryptonote_protocol_handler.h:61
virtual double get_avg_block_size()=0
virtual double estimate_one_block_size() noexcept
Definition: cryptonote_protocol_handler-base.cpp:82
std::unique_ptr< cryptonote_protocol_handler_base_pimpl > mI
Definition: cryptonote_protocol_handler.h:63
void handler_response_blocks_now(size_t packet_size)
Definition: cryptonote_protocol_handler-base.cpp:103
virtual ~cryptonote_protocol_handler_base()
Definition: cryptonote_protocol_handler-base.cpp:97
void handler_request_blocks_history(std::list< crypto::hash > &ids)
Definition: cryptonote_protocol_handler-base.cpp:100
cryptonote_protocol_handler_base()
Definition: cryptonote_protocol_handler-base.cpp:94
Definition: cryptonote_protocol_handler.h:77
std::atomic< bool > m_ask_for_txpool_complement
Definition: cryptonote_protocol_handler.h:164
bool m_sync_pruned_blocks
Definition: cryptonote_protocol_handler.h:177
boost::mutex m_bad_peer_check_lock
Definition: cryptonote_protocol_handler.h:191
virtual bool is_synchronized() const final
Definition: cryptonote_protocol_handler.h:107
epee::math_helper::once_a_time_seconds< 101 > m_sync_search_checker
Definition: cryptonote_protocol_handler.h:169
uint64_t m_last_add_end_time
Definition: cryptonote_protocol_handler.h:173
uint64_t m_sync_download_chain_size
Definition: cryptonote_protocol_handler.h:175
std::atomic< bool > m_no_sync
Definition: cryptonote_protocol_handler.h:163
void set_no_sync(bool value)
Definition: cryptonote_protocol_handler.h:115
bool post_notify(typename t_parameter::request &arg, cryptonote_connection_context &context)
Definition: cryptonote_protocol_handler.h:194
std::atomic< unsigned int > m_max_out_peers
Definition: cryptonote_protocol_handler.h:171
boost::mutex m_buffer_mutex
Definition: cryptonote_protocol_handler.h:187
const block_queue & get_block_queue() const
Definition: cryptonote_protocol_handler.h:110
t_cryptonote_protocol_handler< t_core > cryptonote_protocol_handler
Definition: cryptonote_protocol_handler.h:80
nodetool::i_p2p_endpoint< connection_context > * m_p2p
Definition: cryptonote_protocol_handler.h:159
epee::math_helper::once_a_time_seconds< 8 > m_idle_peer_kicker
Definition: cryptonote_protocol_handler.h:167
block_queue m_block_queue
Definition: cryptonote_protocol_handler.h:166
void set_max_out_peers(unsigned int max)
Definition: cryptonote_protocol_handler.h:113
t_core & m_core
Definition: cryptonote_protocol_handler.h:156
CORE_SYNC_DATA payload_type
Definition: cryptonote_protocol_handler.h:81
epee::math_helper::once_a_time_milliseconds< 100 > m_standby_checker
Definition: cryptonote_protocol_handler.h:168
boost::posix_time::ptime m_sync_start_time
Definition: cryptonote_protocol_handler.h:180
uint64_t m_sync_start_height
Definition: cryptonote_protocol_handler.h:182
bool no_sync() const
Definition: cryptonote_protocol_handler.h:114
std::atomic< uint32_t > m_syncronized_connections_count
Definition: cryptonote_protocol_handler.h:160
std::atomic< bool > m_stopping
Definition: cryptonote_protocol_handler.h:162
epee::math_helper::once_a_time_seconds< 43 > m_bad_peer_checker
Definition: cryptonote_protocol_handler.h:170
nodetool::p2p_endpoint_stub< connection_context > m_p2p_stub
Definition: cryptonote_protocol_handler.h:158
size_t m_block_download_max_size
Definition: cryptonote_protocol_handler.h:176
boost::mutex m_sync_lock
Definition: cryptonote_protocol_handler.h:165
tools::PerformanceTimer m_add_timer
Definition: cryptonote_protocol_handler.h:172
cryptonote_connection_context connection_context
Definition: cryptonote_protocol_handler.h:79
uint64_t m_sync_bad_spans_downloaded
Definition: cryptonote_protocol_handler.h:174
boost::posix_time::ptime m_period_start_time
Definition: cryptonote_protocol_handler.h:181
uint64_t m_period_start_height
Definition: cryptonote_protocol_handler.h:183
std::atomic< bool > m_synchronized
Definition: cryptonote_protocol_handler.h:161
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4
Definition: cryptonote_config.h:97
#define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT
Definition: cryptonote_protocol_handler.h:54
PUSH_WARNINGS
Definition: hash-ops.h:53
const char * name
Definition: simplewallet.cpp:417
Definition: unordered_containers_boost_serialization.h:38
const
Definition: build_protob.py:9
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:37
std::string blobdata
Definition: blobdatatype.h:39
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105
int bool
Definition: stdbool.h:35
Definition: cryptonote_protocol_defs.h:251
Definition: cryptonote_protocol_defs.h:365
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:376
Definition: cryptonote_protocol_defs.h:173
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:186
Definition: cryptonote_protocol_defs.h:323
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:336
Definition: cryptonote_protocol_defs.h:193
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:208
Definition: cryptonote_protocol_defs.h:273
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:286
Definition: cryptonote_protocol_defs.h:343
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:358
Definition: cryptonote_protocol_defs.h:214
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:227
Definition: cryptonote_protocol_defs.h:290
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:316
Definition: cryptonote_protocol_defs.h:231
epee::misc_utils::struct_init< request_t > request
Definition: cryptonote_protocol_defs.h:246
Definition: connection_context.h:43
Definition: cryptonote_protocol_handler_common.h:42
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto