This is the first PR in a planed series of bandwidth / DOS prevention PRs. Focus for now is a simple and not over-complex solution to start with.
The -maxuploadtarget
(in MiB) is a configuration value that make bitcoind try to limit the total outbound traffic. Currently there is no guarantee that the limit target will be fulfilled.
If the target-in-bytes - (time-left-in-24-cycle) / 600 * MAX_BLOCK_SIZE
is reached, stop serve blocks older than one week, stop serve filtered blocks (SPV) immediately.
The timeframe for the measurement is currently fixed to 24h.
This is a effective method of reducing traffic and might prevent node operators from getting expensive “traffic exceed”-bills.
Currently the limit also take effect for whitebinded peers.
Over getnettotals
one can get some upload limit statistics:
0./src/bitcoin-cli getnettotals
1{
2 "totalbytesrecv": 0,
3 "totalbytessent": 0,
4 "timemillis": 1441222000173,
5 "uploadtarget": {
6 "timeframe": 86400,
7 "target": 300000000,
8 "target_reached": false,
9 "serve_historical_blocks": true,
10 "bytes_left_in_cycle": 300000000,
11 "time_left_in_cycle": 86400
12 }
13}
needs documentation needs unit/rpc tests