aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
authorrbrunner7 <rbrunner@dreamshare.ch>2017-11-26 15:26:17 +0100
committerrbrunner7 <rbrunner@dreamshare.ch>2017-11-28 21:18:01 +0100
commitcf5f62361682877a08b246a0d04827c5c4cc30f5 (patch)
treec7feb58c06bf0f3ed0396baa93ea0e95c032887b /src/p2p/net_node.inl
parentMerge pull request #2827 (diff)
downloadmonero-cf5f62361682877a08b246a0d04827c5c4cc30f5.tar.xz
Corrections in rate limiting / trottle code, especially in 'out' direction
Deleted 3 out of 4 calls to method connection_basic::sleep_before_packet that were erroneous / superfluous, which enabled the elimination of a "fudge" factor of 2.1 in connection_basic::set_rate_up_limit; also ended the multiplying of limit values and numbers of bytes transferred by 1024 before handing them over to the global throttle objects
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f64b29c1f..e32eb0c6b 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -72,8 +72,8 @@ namespace nodetool
{
namespace
{
- const int64_t default_limit_up = 2048;
- const int64_t default_limit_down = 8192;
+ const int64_t default_limit_up = 2048; // kB/s
+ const int64_t default_limit_down = 8192; // kB/s
const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"};
const command_line::arg_descriptor<std::string> arg_p2p_bind_port = {
"p2p-bind-port"
@@ -1844,9 +1844,8 @@ namespace nodetool
this->islimitup=false;
}
- limit *= 1024;
epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_up_limit( limit );
- MINFO("Set limit-up to " << limit/1024 << " kB/s");
+ MINFO("Set limit-up to " << limit << " kB/s");
return true;
}
@@ -1858,9 +1857,8 @@ namespace nodetool
limit=default_limit_down;
this->islimitdown=false;
}
- limit *= 1024;
epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_down_limit( limit );
- MINFO("Set limit-down to " << limit/1024 << " kB/s");
+ MINFO("Set limit-down to " << limit << " kB/s");
return true;
}
@@ -1872,21 +1870,21 @@ namespace nodetool
if(limit == -1)
{
- limit_up = default_limit_up * 1024;
- limit_down = default_limit_down * 1024;
+ limit_up = default_limit_up;
+ limit_down = default_limit_down;
}
else
{
- limit_up = limit * 1024;
- limit_down = limit * 1024;
+ limit_up = limit;
+ limit_down = limit;
}
if(!this->islimitup) {
epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_up_limit(limit_up);
- MINFO("Set limit-up to " << limit_up/1024 << " kB/s");
+ MINFO("Set limit-up to " << limit_up << " kB/s");
}
if(!this->islimitdown) {
epee::net_utils::connection<epee::levin::async_protocol_handler<p2p_connection_context> >::set_rate_down_limit(limit_down);
- MINFO("Set limit-down to " << limit_down/1024 << " kB/s");
+ MINFO("Set limit-down to " << limit_down << " kB/s");
}
return true;