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 downloads the blockchain very fast, and never allows more than 60 seconds (the default) of inactivity to occur, so recovers very quickly from stuck downloads. With my testing, this can safely be reduced to 10 seconds as 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.
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.