2 global variables are currently enough for basechainparams and CChainParams, but we’re
using N + 1 globals instead. Although N is likely to remain 3 for the
foreseeable future (and not many people seemed interested in turning N
into infinite in #6382) I believe segwit was an example on how starting a new testchain can be very useful and anything that makes that easier is potentially valuable.
Traceability: Replaces #6907. Changes from final non-merged #6907:
- Of course, there were new uses of CChainParams& Params(std::string)
- post-segwit: UpdateRegtestBIP9Parameters is replaced with UpdateBIP9Parameters since we don’t have a separate global for regtest anymore. An additional assert/error could be added if we wanted to restrict its usage beyond regtest, bit I don’t think the restriction makes sense. Remember that Params() now returns a const ref and init.cpp was the only context was the only context where UpdateRegtestBIP9Parameters was called from.
- post-C++11: s/boost::scoped_ptr/std::unique_ptr/ as in #8629
- Return a std::unique_ptr directly instead of a CChainParams*
- testChainParams could be confused as meaning params from testnet (changed to chainParams)
- Changes to checkpoint tests no longer required after #9053