Update of the PR with network limits
works very well for all speeds
(but remember that low download speed can stop upload
because we then slow down downloading of blockchain
requests too)
more debug options
fixed pedantic warnings in our code
should work again on Mac OS X and FreeBSD
fixed warning about size_t
tested on Debian, Ubuntu, Windows(testing now)
TCP options and ToS (QoS) flag
FIXED peer number limit
FIXED some spikes in ingress/download
FIXED problems when other up and down limit
#error "You requested to turn off terminal colors (CFG_WITH_TERMCOLORS), however currently they are hardcoded (this option to turn them off is not yet implemented)."
//#error "You requested to turn off terminal colors (CFG_WITH_TERMCOLORS), however currently they are hardcoded (this option to turn them off is not yet implemented)."
#endif
#endif
///Macros related to automatic deduction of class name etc;
///Macros related to automatic deduction of class name etc;
@ -35,7 +35,7 @@ class myexception : public std::runtime_error {
};
};
/// @macro Use this macro INJECT_OT_COMMON_USING_NAMESPACE_COMMON_1 as a shortcut for various using std::string etc.
/// @macro Use this macro INJECT_OT_COMMON_USING_NAMESPACE_COMMON_1 as a shortcut for various using std::string etc.
constchar*DbgShortenCodeFileName(constchar*s);///< Returns a pointer to some part of the string that was given, skipping directory names, for log/debug
constchar*DbgShortenCodeFileName(constchar*s);///< Returns a pointer to some part of the string that was given, skipping directory names, for log/debug
// return m_core.get_blockchain_storage().get_avg_block_size(count); // this does not count too well the actuall network-size of data we need to download
CRITICAL_REGION_LOCAL(m_buffer_mutex);
double avg = 0;
if (m_avg_buffer.size() == 0) {
_warn("m_avg_buffer.size() == 0");
return 500;
}
const bool dbg_poke_lock = 0; // debug: try to trigger an error by poking around with locks. TODO: configure option
long int dbg_repeat=0;
do {
for (auto element : m_avg_buffer) avg += element;
} while(dbg_poke_lock && (dbg_repeat++)<100000); // in debug/poke mode, repeat this calculation to trigger hidden locking error if there is one
return avg / m_avg_buffer.size();
}
}
@ -341,6 +394,41 @@ namespace cryptonote
int t_cryptonote_protocol_handler<t_core>::handle_response_get_objects(int command, NOTIFY_RESPONSE_GET_OBJECTS::request& arg, cryptonote_connection_context& context)
int t_cryptonote_protocol_handler<t_core>::handle_response_get_objects(int command, NOTIFY_RESPONSE_GET_OBJECTS::request& arg, cryptonote_connection_context& context)
,"Run on testnet. The wallet must be launched with --testnet flag."
,"Run on testnet. The wallet must be launched with --testnet flag."
,false
,false
};
};
constcommand_line::arg_descriptor<bool>arg_dns_checkpoints={"enforce-dns-checkpointing","checkpoints from DNS server will be enforced",false};
constcommand_line::arg_descriptor<bool>arg_dns_checkpoints={"enforce-dns-checkpointing","checkpoints from DNS server will be enforced",false};
constcommand_line::arg_descriptor<bool>arg_test_drop_download={"test-drop-download","For network testing, drop downloaded blocks instead checking/adding them to blockchain. Can fake-download blocks very fast."};
constcommand_line::arg_descriptor<bool>arg_save_graph={"save-graph","Save data for dr monero",false};
m_cmd_binder.set_handler("test_drop_download",boost::bind(&daemon_cmmands_handler::test_drop_download,this,_1),"For network testing, drop downloaded blocks instead checking/adding them to blockchain. Can fake-download blocks very fast.");
// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
#ifdef UPNP_STATIC
#ifdef UPNP_STATIC
@ -85,8 +86,8 @@ namespace nodetool
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
const command_line::arg_descriptor<bool> arg_no_igd= {"no-igd", "Disable UPnP port mapping"};
const command_line::arg_descriptor<bool> arg_no_igd= {"no-igd", "Disable UPnP port mapping"};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max limit of out peers", -1};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max limit of out peers", -1};
const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
virtualnetwork_time_secondstime_to_slot(network_time_secondst)const{returnstd::floor(t);}// convert exact time eg 13.7 to rounded time for slot number in history 13
virtualnetwork_time_secondstime_to_slot(network_time_secondst)const{returnstd::floor(t);}// convert exact time eg 13.7 to rounded time for slot number in history 13
virtualvoidhandle_trafic_exact(size_tpacket_size)=0;// count the new traffic/packet; the size is exact considering all network costs
virtualvoidhandle_trafic_exact(size_tpacket_size)=0;// count the new traffic/packet; the size is exact considering all network costs
virtualvoidhandle_trafic_tcp(size_tpacket_size)=0;// count the new traffic/packet; the size is as TCP, we will consider MTU etc
virtualvoidhandle_trafic_tcp(size_tpacket_size)=0;// count the new traffic/packet; the size is as TCP, we will consider MTU etc
virtualvoidhandle_congestion(doubleoverheat)=0;// call this when congestion is detected; see example use
virtualvoidtick()=0;// poke and update timers/history
virtualvoidtick()=0;// poke and update timers/history
// time calculations:
// time calculations:
@ -166,8 +166,6 @@ class i_network_throttle {
virtualsize_tget_recommended_size_of_planned_transport()const=0;// what should be the recommended limit of data size that we can transport over current network_throttle in near future
virtualsize_tget_recommended_size_of_planned_transport()const=0;// what should be the recommended limit of data size that we can transport over current network_throttle in near future