Encapsulate miner-related pow in ScanHash

Continues #4506.
Following @laanwj 's advice of only moving ScanHash, I found another solution to encapsulate the miner's pow without removing the miner's optimization, which was rejected in #4423 
But I would like to slightly change the behavior.
Commit "Replace proof.nNonce >= 0xffff000 with an iteration counter" should be either rejected or squashed into "proof.nNonce >= 0xffff0000 -> proof.OutOfRangeSolution()" (and of course that 1000 in the for is open for bike-shedding).
"Small miner optimization" also should be rejected or rebased in "Remove testnet's special case from miner.cpp".
I think these 2 functional changes are meaningless enough that can be safely accepted.
I would also be happy to just remove the hashmeter and the resulting PR would be simpler.
Why turn this into a global? It's ugly, and I don't think it will actually work in case of multiple hasher threads...