Refactor/encapsulate chain globals into a CChain class
Merge pull request #3077 from sipa/chain

Refactor/encapsulate chain globals into a CChain class