This is a simpler alternative to #5463, in order to solve #5588.
Disconnect peers which take longer than block interval time to download a block from, with extra time given in case the block was requested with existing parallel downloads queued.
This will disconnect peers that do not transfer a block in 10 minutes, plus
5 minutes for every previously queued block with validated headers
(accomodating downstream bandwidth down to a few kilobytes per second - below
that the node would have trouble staying synchronized anyway).
4528 | @@ -4522,6 +4529,10 @@ bool SendMessages(CNode* pto, bool fSendTrickle) 4529 | LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->id); 4530 | pto->fDisconnect = true; 4531 | } 4532 | + if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().TargetSpacing() * (2 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
This (complicated) conditional expression needs a comment on what the intent is
Added a comment.
4533 | @@ -4527,6 +4534,15 @@ bool SendMessages(CNode* pto, bool fSendTrickle) 4534 | LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->id); 4535 | pto->fDisconnect = true; 4536 | } 4537 | + // In case there is a block that has been in flight from this peer for (1 + 0.5 * N) times the block interval
Nice, utACK
I've been playing with this and it looks good to me for a short term fix, subject to the limitations discussed on IRC on 1/7 with respect to backoffs and ping timeouts being triggered at the hard 20m limit when ping replies get stuck behind a bunch of slow moving blocks. Ran a full sync and several catch-ups from -7d with no issues. Also verified that clients are indeed disconnected.
Post-armageddon, will this disconnect my last satellite block source for being too slow?
yup. But you were doomed by the zombies before that point anyways. (more seriously: you're guaranteed to fall behind: better to see no connections than to think you're up to date)
Milestone
0.10.0