From b27e81f115e67bffee2c35c1c96082879160f6e1 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 6 Nov 2015 00:05:06 +0100 Subject: [PATCH 1/2] [net] Cleanup maxuploadtarget * log: nMaxOutboundLimit is in bytes * log: Hide misleading -maxuploadtarget=0 warning * qa : Minor cleanup to maxuploadtarget rpc tests * net: Use DEFAULT_MAX_UPLOAD_TARGET = 0 --- qa/rpc-tests/maxuploadtarget.py | 3 ++- src/init.cpp | 4 ++-- src/net.cpp | 4 ++-- src/net.h | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qa/rpc-tests/maxuploadtarget.py b/qa/rpc-tests/maxuploadtarget.py index 67c4a5098..148c5f37e 100755 --- a/qa/rpc-tests/maxuploadtarget.py +++ b/qa/rpc-tests/maxuploadtarget.py @@ -192,7 +192,8 @@ class MaxUploadTest(BitcoinTestFramework): getdata_request.inv.append(CInv(2, big_old_block)) max_bytes_per_day = 200*1024*1024 - max_bytes_available = max_bytes_per_day - 144*1000000 + daily_buffer = 144 * 1000000 + max_bytes_available = max_bytes_per_day - daily_buffer success_count = max_bytes_available / old_block_size # 144MB will be reserved for relaying new blocks, so expect this to diff --git a/src/init.cpp b/src/init.cpp index 87a23deab..a83a136fa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -375,7 +375,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-whitebind=", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6")); strUsage += HelpMessageOpt("-whitelist=", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") + " " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway")); - strUsage += HelpMessageOpt("-maxuploadtarget=", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), 0)); + strUsage += HelpMessageOpt("-maxuploadtarget=", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET)); #ifdef ENABLE_WALLET strUsage += HelpMessageGroup(_("Wallet options:")); @@ -1193,7 +1193,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif if (mapArgs.count("-maxuploadtarget")) { - CNode::SetMaxOutboundTarget(GetArg("-maxuploadtarget", 0)*1024*1024); + CNode::SetMaxOutboundTarget(GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024); } // ********************************************************* Step 7: load block chain diff --git a/src/net.cpp b/src/net.cpp index ada4a1bb6..1ea50b249 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2117,8 +2117,8 @@ void CNode::SetMaxOutboundTarget(uint64_t limit) uint64_t recommendedMinimum = (nMaxOutboundTimeframe / 600) * MAX_BLOCK_SIZE; nMaxOutboundLimit = limit; - if (limit < recommendedMinimum) - LogPrintf("Max outbound target is very small (%s) and will be overshot. Recommended minimum is %s\n.", nMaxOutboundLimit, recommendedMinimum); + if (limit > 0 && limit < recommendedMinimum) + LogPrintf("Max outbound target is very small (%s bytes) and will be overshot. Recommended minimum is %s bytes.\n", nMaxOutboundLimit, recommendedMinimum); } uint64_t CNode::GetMaxOutboundTarget() diff --git a/src/net.h b/src/net.h index d89244523..cd2d225d7 100644 --- a/src/net.h +++ b/src/net.h @@ -60,6 +60,8 @@ static const bool DEFAULT_UPNP = false; static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ; /** The maximum number of peer connections to maintain. */ static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125; +/** The default for -maxuploadtarget. 0 = Unlimited */ +static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0; unsigned int ReceiveFloodSize(); unsigned int SendBufferSize(); From 9c3ee3bf77382aca5717f9ae7163e79e3bf836af Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 6 Nov 2015 00:01:51 +0100 Subject: [PATCH 2/2] [doc] Add -maxuploadtarget release notes --- doc/release-notes.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/release-notes.md b/doc/release-notes.md index 31704ba47..2e9cc1694 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -168,6 +168,25 @@ a connection to Tor can be made. It can be configured with the `-listenonion`, `-torcontrol` and `-torpassword` settings. To show verbose debugging information, pass `-debug=tor`. +Reduce upload traffic +--------------------- + +A major part of the outbound traffic is caused by serving historic blocks to +other nodes in initial block download state. + +It is now possible to reduce the total upload traffic via the `-maxuploadtarget` +parameter. This is *not* a hard limit but a threshold to minimize the outbound +traffic. When the limit is about to be reached, the uploaded data is cut by not +serving historic blocks (blocks older than one week). +Moreover, any SPV peer is disconnected when they request a filtered block. + +This option can be specified in MiB per day and is turned off by default +(`-maxuploadtarget=0`). +The recommended minimum is 144 * MAX_BLOCK_SIZE (currently 144MB) per day. + +A more detailed documentation about keeping traffic low can be found in +[/doc/reducetraffic.md](/doc/reducetraffic.md). + 0.12.0 Change log =================