Electroneum
Loading...
Searching...
No Matches
cryptonote::cryptonote_protocol_handler_base Class Referenceabstract

#include <cryptonote_protocol_handler.h>

Inheritance diagram for cryptonote::cryptonote_protocol_handler_base:

Public Member Functions

 cryptonote_protocol_handler_base ()
virtual ~cryptonote_protocol_handler_base ()
void handler_request_blocks_history (std::list< crypto::hash > &ids)
void handler_response_blocks_now (size_t packet_size)
virtual double get_avg_block_size ()=0
virtual double estimate_one_block_size () noexcept

Detailed Description

Definition at line 62 of file cryptonote_protocol_handler.h.

Constructor & Destructor Documentation

◆ cryptonote_protocol_handler_base()

cryptonote::cryptonote_protocol_handler_base::cryptonote_protocol_handler_base ( )

Definition at line 95 of file cryptonote_protocol_handler-base.cpp.

95 {
96}

◆ ~cryptonote_protocol_handler_base()

cryptonote::cryptonote_protocol_handler_base::~cryptonote_protocol_handler_base ( )
virtual

Definition at line 98 of file cryptonote_protocol_handler-base.cpp.

98 {
99}

Member Function Documentation

◆ estimate_one_block_size()

double cryptonote::cryptonote_protocol_handler_base::estimate_one_block_size ( )
virtualnoexcept

Definition at line 83 of file cryptonote_protocol_handler-base.cpp.

83 { // for estimating size of blocks to downloa
84 const double size_min = 500; // XXX 500
85 //const int history_len = 20; // how many blocks to average over
86
87 double avg=0;
88 try {
89 avg = get_avg_block_size(/*history_len*/);
90 } catch (...) { }
91 avg = std::max( size_min , avg);
92 return avg;
93}
Here is the call graph for this function:

◆ get_avg_block_size()

virtual double cryptonote::cryptonote_protocol_handler_base::get_avg_block_size ( )
pure virtual
Here is the caller graph for this function:

◆ handler_request_blocks_history()

void cryptonote::cryptonote_protocol_handler_base::handler_request_blocks_history ( std::list< crypto::hash > & ids)

Definition at line 101 of file cryptonote_protocol_handler-base.cpp.

101 {
102}

◆ handler_response_blocks_now()

void cryptonote::cryptonote_protocol_handler_base::handler_response_blocks_now ( size_t packet_size)

Definition at line 104 of file cryptonote_protocol_handler-base.cpp.

104 {
105 using namespace epee::net_utils;
106 double delay=0; // will be calculated
107 MDEBUG("Packet size: " << packet_size);
108 do
109 { // rate limiting
110 //XXX
111 /*if (::cryptonote::core::get_is_stopping()) {
112 MDEBUG("We are stopping - so abort sleep");
113 return;
114 }*/
115 /*if (m_was_shutdown) {
116 MDEBUG("m_was_shutdown - so abort sleep");
117 return;
118 }*/
119
120 {
121 CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
122 delay = network_throttle_manager::get_global_throttle_out().get_sleep_time_after_tick( packet_size );
123 }
124
125
126 delay *= 0.50;
127 //delay = 0; // XXX
128 if (delay > 0) {
129 //delay += rand2*0.1;
130 long int ms = (long int)(delay * 1000);
131 MDEBUG("Sleeping for " << ms << " ms before packet_size="<<packet_size); // XXX debug sleep
132 boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) ); // TODO randomize sleeps
133 }
134 } while(delay > 0);
135
136// XXX LATER XXX
137 {
138 CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
139 network_throttle_manager::get_global_throttle_out().handle_trafic_tcp( packet_size ); // increase counter - global
140 //epee::critical_region_t<decltype(m_throttle_global_lock)> guard(m_throttle_global_lock); // *** critical ***
141 //m_throttle_global.m_out.handle_trafic_tcp( packet_size ); // increase counter - global
142 }
143}
#define MDEBUG(x)
Definition misc_log_ex.h:76
#define CRITICAL_REGION_LOCAL(x)
Definition syncobj.h:228
Here is the call graph for this function:

The documentation for this class was generated from the following files: