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:
./src/bitcoin-cli getnettotals
{
"totalbytesrecv": 0,
"totalbytessent": 0,
"timemillis": 1441222000173,
"uploadtarget": {
"timeframe": 86400,
"target": 300000000,
"target_reached": false,
"serve_historical_blocks": true,
"bytes_left_in_cycle": 300000000,
"time_left_in_cycle": 86400
}
}
needs documentation needs unit/rpc tests