sync: Add CTimeoutCondition

A condition that can wait for a specified timeout, this is useful when
it is known in advance that events have to be processed at some time in the
future.
net: add StartThreads and StopThreads signals

This allows modules to maintain their own threads.
net: Better inventory request management
Add CaughtUp() function (needed by later commits)
Improve getheaders logging
debug "block"
Use syncheight instead of startheight for broadcasting block invs
Better logging of stalling
Fix stall timeout
Display error when duplicate block received
Only send initial getheaders when !CaughtUp()
Change check whether to send block inv after UpdateTip
Add height to "Requesting block" debug
Don't getdata blocks as soon as the invs are seen. (wait for the headers instead)
Fix logic for nSyncStarted (only increases when headers actually arrive).
Re-introduce mapAskFor (so that we don't waste getdata messages with only 1 inv in each one)
Add debug "tx" and "tx2" options
Process "notfound" messages, and safeguard against unreasonably long ones.
Cleanup messy error messages
Rearrange ProcessMessages