Prevent stuck block download in large reorganisations

In cases of very large reorganisations (hundreds of blocks), a situation
may appear where an 'inv' is sent as response to a 'getblocks', but the
last block mentioned in the inv is already known to the receiver node.
However, the supplying node uses a request for this last block as a
trigger to send the rest of the inv blocks. If it never comes, the block
chain download is stuck.

This commit makes the receiver node always request the last inv'ed block,
even if it is already known, to prevent this problem.
Prevent stuck download: correct solution

Pull request #948 introduced a fix for nodes stuck on a long side branch
of the main chain. The fix was non-functional however, as the additional
getdata request was created in a first step of processing, but dropped
in a second step as it was considered redundant. This commits fixes it
by sending the request directly.
Hopefully final fix for the stuck blockchain issue

Immediately issue a "getblocks", instead of a "getdata" (which will
trigger the relevant "inv" to be sent anyway), and only do so when
the previous set of invs led us into a known and attached part of
the block tree.
Speed up RPC authentication (reworked pull from Joel Katz)
Faster Base64 decoder.
Use transactions-updated as flush condition

The normal checkpointing during the block chain download is reduced
to every five minutes only, but forced every 200000 updated transactions.

Backported from bitcoin commit 25c5eca8939832e94556810ae30f1f7830e1c29c
Flush on log size instead of transaction count

Backported from bitcoin commit e88ed65a39eb86ffd4d0720852d7e5f3d021f792
temp
Highlight mis-matching locks
If compiled -DDEBUG_LOCKORDER and run with -debug, print out every mutex lock/unlock (helpful for debugging something-is-holding-a-mutex-too-long problems)