bitcoin/bitcoin — pull request #4431 by rebroad (2014-06-27 13:18:10+00:00)
Title: Fix many orphan problem and stuck block download problem

Needs a rebase. i'll do this next.

This has taken me several days to code and test, and I've tested it thoroughly.

With the current code, that uses only one syncnode, with these changes, the node will never download orphan blocks. With net debugging enabled, you will get a good view of what it's doing.

It also logs various useful metrics, such as download speed, ping times, etc.

It also downloads the blockchain very fast, and never allows more than 10 seconds of inactivity to occur, so recovers very quickly from stuck downloads. From my testing, if a downloads sticks for as long as 10 seconds, it never recovers, so rather than wait two minutes as the current code does (well, tries to do), it quickly switches to a new syncnode.

Next to do is to improve the syncnode selection algorithm as this can use the metrics that I've been collecting (e.g. ping times, download speed, etc) instead of the very simple metric so far.

Please do test, and give comments. So far, with the orphan problem, many people are unable to run the node without limiting orphan blocks (which still doesn't fix the stuck download anyway).

Feel free to copy this branch and improve it. I've included quite a few commits to make it easier to see the development process, but I won't always have time to make the changes needed that people ask for, and from experience my pull requests often don't get pulled for some reason. I think this functionality is needed now based upon the issues people have been raising.