Refactor/encapsulate chain globals into a CChain class

This removes several globals (pindexBest, hashBestChain, nBestHeight, nBestChainWork, vBlockIndexByHeight), and turns them into an instance of a CChain class, chainBlocks.

This is a preparation for a second iteration of headersfirst which I'm implementing, which will add a second instance (chainHeaders). This pull request shouldn't change any functionality.