files: #!/usr/bin/env python3
  # Copyright (c) 2014-2015 The Bitcoin Core developers
  # Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  # Distributed under the MIT software license, see the accompanying
  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  """
  Run Regression Test Suite
  
  This module calls down into individual test cases via subprocess. It will
  forward all unrecognized arguments onto the individual test scripts, other
  than:
  
      - `-h` or '--help': print help about all options
      - `-extended`: run the "extended" test suite in addition to the basic one.
      - `-extended-only`: run ONLY the "extended" test suite
      - `-list`: only list the test scripts, do not run. Works in combination
        with '-extended' and '-extended-only' too, to print subsets.
      - `-win`: signal that this is running in a Windows environment, and we
        should run the tests.
      - `--coverage`: this generates a basic coverage report for the RPC
        interface.
  
  For more detailed help on options, run with '--help'.
  
  For a description of arguments recognized by test scripts, see
  `qa/pull-tester/test_framework/test_framework.py:BitcoinTestFramework.main`.
  
  """
  import pdb
  import os
  import time
  import shutil
  import sys
  import subprocess
  import tempfile
  import re
  
  sys.path.append("qa/pull-tester/")
  from tests_config import *
  from test_classes import RpcTest, Disabled, Skip
  
  BOLD = ("","")
  if os.name == 'posix':
      # primitive formatting on supported
      # terminal via ANSI escape sequences:
      BOLD = ('\033[0m', '\033[1m')
  
  RPC_TESTS_DIR = SRCDIR + '/qa/rpc-tests/'
  
  #If imported values are not defined then set to zero (or disabled)
  if 'ENABLE_WALLET' not in vars():
      ENABLE_WALLET=0
  if 'ENABLE_BITCOIND' not in vars():
      ENABLE_BITCOIND=0
  if 'ENABLE_UTILS' not in vars():
      ENABLE_UTILS=0
  if 'ENABLE_ZMQ' not in vars():
      ENABLE_ZMQ=0
  
  ENABLE_COVERAGE=0
  
  #Create a set to store arguments and create the passOn string
  opts = set()
  double_opts = set()  # BU: added for checking validity of -- opts
  passOn = ""
  showHelp = False  # if we need to print help
  p = re.compile("^--")
  # some of the single-dash options applicable only to this runner script
  # are also allowed in double-dash format (but are not passed on to the
  # test scripts themselves)
  private_single_opts = ('-h',
                         '-f',    # equivalent to -force-enable
                         '-help',
                         '-list',
                         '-extended',
                         '-extended-only',
                         '-only-extended',
                         '-force-enable',
                         '-win')
  private_double_opts = ('--list',
                         '--extended',
                         '--extended-only',
                         '--only-extended',
                         '--force-enable',
                         '--win')
  framework_opts = ('--tracerpc',
                    '--help',
                    '--noshutdown',
                    '--nocleanup',
                    '--srcdir',
                    '--tmpdir',
                    '--coveragedir',
                    '--randomseed',
                    '--testbinary',
                    '--refbinary')
  test_script_opts
  
  [... the rest is omitted ...]
files: qa/pull-tester/rpc-tests.py
files: #!/usr/bin/env python3
  # Copyright (c) 2014-2015 The Bitcoin Core developers
  # Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  # Distributed under the MIT software license, see the accompanying
  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  """
  Run Regression Test Suite
  
  This module calls down into individual test cases via subprocess. It will
  forward all unrecognized arguments onto the individual test scripts, other
  than:
  
      - `-h` or '--help': print help about all options
      - `-extended`: run the "extended" test suite in addition to the basic one.
      - `-extended-only`: run ONLY the "extended" test suite
      - `-list`: only list the test scripts, do not run. Works in combination
        with '-extended' and '-extended-only' too, to print subsets.
      - `-win`: signal that this is running in a Windows environment, and we
        should run the tests.
      - `--coverage`: this generates a basic coverage report for the RPC
        interface.
  
  For more detailed help on options, run with '--help'.
  
  For a description of arguments recognized by test scripts, see
  `qa/pull-tester/test_framework/test_framework.py:BitcoinTestFramework.main`.
  
  """
  import pdb
  import os
  import time
  import shutil
  import sys
  import subprocess
  import tempfile
  import re
  
  sys.path.append("qa/pull-tester/")
  from tests_config import *
  from test_classes import RpcTest, Disabled, Skip
  
  BOLD = ("","")
  if os.name == 'posix':
      # primitive formatting on supported
      # terminal via ANSI escape sequences:
      BOLD = ('\033[0m', '\033[1m')
  
  RPC_TESTS_DIR = SRCDIR + '/qa/rpc-tests/'
  
  #If imported values are not defined then set to zero (or disabled)
  if 'ENABLE_WALLET' not in vars():
      ENABLE_WALLET=0
  if 'ENABLE_BITCOIND' not in vars():
      ENABLE_BITCOIND=0
  if 'ENABLE_UTILS' not in vars():
      ENABLE_UTILS=0
  if 'ENABLE_ZMQ' not in vars():
      ENABLE_ZMQ=0
  
  ENABLE_COVERAGE=0
  
  #Create a set to store arguments and create the passOn string
  opts = set()
  double_opts = set()  # BU: added for checking validity of -- opts
  passOn = ""
  showHelp = False  # if we need to print help
  p = re.compile("^--")
  # some of the single-dash options applicable only to this runner script
  # are also allowed in double-dash format (but are not passed on to the
  # test scripts themselves)
  private_single_opts = ('-h',
                         '-f',    # equivalent to -force-enable
                         '-help',
                         '-list',
                         '-extended',
                         '-extended-only',
                         '-only-extended',
                         '-force-enable',
                         '-win')
  private_double_opts = ('--list',
                         '--extended',
                         '--extended-only',
                         '--only-extended',
                         '--force-enable',
                         '--win')
  framework_opts = ('--tracerpc',
                    '--help',
                    '--noshutdown',
                    '--nocleanup',
                    '--srcdir',
                    '--tmpdir',
                    '--coveragedir',
                    '--randomseed',
                    '--testbinary',
                    '--refbinary')
  test_script_opts
  
  [... the rest is omitted ...]
files: qa/pull-tester/rpc-tests.py
files: #!/usr/bin/env python3
  # Copyright (c) 2014-2015 The Bitcoin Core developers
  # Copyright (c) 2015-2016 The Bitcoin Unlimited developers
  # Distributed under the MIT software license, see the accompanying
  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  
  from test_framework.test_framework import BitcoinTestFramework
  from test_framework.util import *
  
  class ParallelTest (BitcoinTestFramework):
      def __init__(self):
        self.rep = False
        #self.extensive = False
        BitcoinTestFramework.__init__(self)
  
      def setup_chain(self):
          print ("Initializing test directory "+self.options.tmpdir)
          initialize_chain_clean(self.options.tmpdir, 6)
  
      def setup_network(self, split=False):
          self.nodes = []
          self.nodes.append(start_node(0, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(1, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(2, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(3, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          interconnect_nodes(self.nodes)
          self.is_network_split=False
          self.sync_all()
  
      def repetitiveTest(self):
          # get some coins
          self.nodeLookup = {}
          i = 0
          for n in self.nodes:
            print("Node %d is %s" % (i,n.url))
            print ("generating coins for node")  
            n.generate(200)
            self.sync_all()
            i += 1
            
          for i in range(0,200):
            # Create many utxo's
            print ("round %d: Generating txns..." % i)
            for n in self.nodes:  
              send_to = {}
              n.keypoolrefill(100)
              n.keypoolrefill(100)
              for i in range(200):
                send_to[n.getnewaddress()] = Decimal("0.01")
              n.sendmany("", send_to)
  
              self.sync_all()
            print ("  generating blocks...")
            i = 0
            for n in self.nodes:
              try:
                  n.generate(1)
              except JSONRPCException as e:
                  print (e)
                  print ("Node ", i, " ", n.url)
                  pdb.set_trace()
              i += 1
            print ("  syncing...")
            self.sync_all()
                      
      def run_test (self):
          if self.rep:
              self.repetitiveTest()
              return
  
          print ("Mining blocks with PV off...")
  
          # Mine some blocks on node2 which we will need at the end to generate a
  
  [... the rest is omitted ...]
files: qa/rpc-tests/parallel.py
files: #!/usr/bin/env python3
  # Copyright (c) 2014-2015 The Bitcoin Core developers
  # Copyright (c) 2015-2016 The Bitcoin Unlimited developers
  # Distributed under the MIT software license, see the accompanying
  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  
  from test_framework.test_framework import BitcoinTestFramework
  from test_framework.util import *
  
  class ParallelTest (BitcoinTestFramework):
      def __init__(self):
        self.rep = False
        BitcoinTestFramework.__init__(self)
  
      def setup_chain(self):
          print ("Initializing test directory "+self.options.tmpdir)
          initialize_chain_clean(self.options.tmpdir, 6)
  
      def setup_network(self, split=False):
          self.nodes = []
          self.nodes.append(start_node(0, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(1, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(2, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          self.nodes.append(start_node(3, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
          interconnect_nodes(self.nodes)
          self.is_network_split=False
          self.sync_all()
  
      def repetitiveTest(self):
          # get some coins
          self.nodeLookup = {}
          i = 0
          for n in self.nodes:
            print("Node %d is %s" % (i,n.url))
            print ("generating coins for node")  
            n.generate(200)
            self.sync_all()
            i += 1
            
          for i in range(0,200):
            # Create many utxo's
            print ("round %d: Generating txns..." % i)
            for n in self.nodes:  
              send_to = {}
              n.keypoolrefill(100)
              n.keypoolrefill(100)
              for i in range(200):
                send_to[n.getnewaddress()] = Decimal("0.01")
              n.sendmany("", send_to)
  
              self.sync_all()
            print ("  generating blocks...")
            i = 0
            for n in self.nodes:
              try:
                  n.generate(1)
              except JSONRPCException as e:
                  print (e)
                  print ("Node ", i, " ", n.url)
                  pdb.set_trace()
              i += 1
            print ("  syncing...")
            self.sync_all()
                      
      def run_test (self):
          if self.rep:
              self.repetitiveTest()
              return
          
          print ("Mining blocks with PV off...")
  
          # Mine some blocks on node2 which we will need at the end to generate a few transactions from that node
          #
  
  [... the rest is omitted ...]
files: qa/rpc-tests/parallel.py
files: // Copyright (c) 2017 Stephen McCarthy
  // Copyright (c) 2017 The Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include <set>
  
  #include "allowed_args.h"
  #include "chainparams.h"
  #include "dosman.h"
  #include "httpserver.h"
  #include "init.h"
  #include "main.h"
  #include "miner.h"
  #include "netbase.h"
  #include "policy/policy.h"
  #include "qt/guiconstants.h"
  #include "requestManager.h"
  #include "script/sigcache.h"
  #include "tinyformat.h"
  #include "torcontrol.h"
  #include "tweak.h"
  #include "txdb.h"
  #include "util.h"
  #include "utilmoneystr.h"
  #include "utilstrencodings.h"
  
  #ifdef ENABLE_WALLET
  #include "wallet/wallet.h"
  #endif
  
  // These globals are needed here so bitcoin-cli can link
  const std::string CURRENCY_UNIT = "BTC";
  const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051";
  const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
  
  // Variables for traffic shaping.  Needed here so bitcoin-cli can link
  /** Default value for the maximum amount of data that can be received in a burst */
  const int64_t DEFAULT_MAX_RECV_BURST = std::numeric_limits<int64_t>::max();
  /** Default value for the maximum amount of data that can be sent in a burst */
  const int64_t DEFAULT_MAX_SEND_BURST = std::numeric_limits<int64_t>::max();
  /** Default value for the average amount of data received per second */
  const int64_t DEFAULT_AVE_RECV = std::numeric_limits<int64_t>::max();
  /** Default value for the average amount of data sent per second */
  const int64_t DEFAULT_AVE_SEND = std::numeric_limits<int64_t>::max();
  
  namespace AllowedArgs
  {
  enum HelpMessageMode
  {
      HMM_BITCOIND,
      HMM_BITCOIN_QT
  };
  
  static const int screenWidth = 79;
  static const int optIndent = 2;
  static const int msgIndent = 7;
  
  std::string HelpMessageGroup(const std::string &message) { return std::string(message) + std::string("\n\n"); }
  std::string HelpMessageOpt(const std::string &option, const std::string &message)
  {
      return std::string(optIndent, ' ') + std::string(option) + std::string("\n") + std::string(msgIndent, ' ') +
             FormatParagraph(message, screenWidth - msgIndent, msgIndent) + std::string("\n\n");
  }
  
  AllowedArgs::AllowedArgs(bool permit_unrecognized) : m_permit_unrecognized(permit_unrecognized) {}
  AllowedArgs &AllowedArgs::addHeader(const std::string &strHeader, bool debug)
  {
      m_helpList.push_back(HelpComponent{strHeader + "\n\n", debug});
      return *this;
  }
  
  AllowedArgs &AllowedArgs::addDebugArg(const std::string &strArgsDefinition,
      CheckValueFunc checkValueFunc,
      const std::string &strHelp)
  {
      return addArg(strArgsDefinition, checkValueFunc, strHelp, true);
  }
  
  AllowedArgs &AllowedArgs::addArg(const std::string &strArgsDefinition,
      CheckValueFunc checkValueFunc,
      const std::string &strHelp,
      bool debug)
  {
      std::string strArgs = strArgsDefinition;
      std::string strExampleValue;
      size_t is_index = strArgs
  
  [... the rest is omitted ...]
files: src/allowed_args.cpp
files: // Copyright (c) 2017 Stephen McCarthy
  // Copyright (c) 2017 The Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include <set>
  
  #include "allowed_args.h"
  #include "chainparams.h"
  #include "dosman.h"
  #include "httpserver.h"
  #include "init.h"
  #include "main.h"
  #include "miner.h"
  #include "netbase.h"
  #include "policy/policy.h"
  #include "qt/guiconstants.h"
  #include "requestManager.h"
  #include "script/sigcache.h"
  #include "tinyformat.h"
  #include "torcontrol.h"
  #include "tweak.h"
  #include "txdb.h"
  #include "util.h"
  #include "utilmoneystr.h"
  #include "utilstrencodings.h"
  
  #ifdef ENABLE_WALLET
  #include "wallet/wallet.h"
  #endif
  
  // These globals are needed here so bitcoin-cli can link
  const std::string CURRENCY_UNIT = "BTC";
  const std::string DEFAULT_TOR_CONTROL = "127.0.0.1:9051";
  const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
  
  // Variables for traffic shaping.  Needed here so bitcoin-cli can link
  /** Default value for the maximum amount of data that can be received in a burst */
  const int64_t DEFAULT_MAX_RECV_BURST = std::numeric_limits<int64_t>::max();
  /** Default value for the maximum amount of data that can be sent in a burst */
  const int64_t DEFAULT_MAX_SEND_BURST = std::numeric_limits<int64_t>::max();
  /** Default value for the average amount of data received per second */
  const int64_t DEFAULT_AVE_RECV = std::numeric_limits<int64_t>::max();
  /** Default value for the average amount of data sent per second */
  const int64_t DEFAULT_AVE_SEND = std::numeric_limits<int64_t>::max();
  
  namespace AllowedArgs
  {
  enum HelpMessageMode
  {
      HMM_BITCOIND,
      HMM_BITCOIN_QT
  };
  
  static const int screenWidth = 79;
  static const int optIndent = 2;
  static const int msgIndent = 7;
  
  std::string HelpMessageGroup(const std::string &message) { return std::string(message) + std::string("\n\n"); }
  std::string HelpMessageOpt(const std::string &option, const std::string &message)
  {
      return std::string(optIndent, ' ') + std::string(option) + std::string("\n") + std::string(msgIndent, ' ') +
             FormatParagraph(message, screenWidth - msgIndent, msgIndent) + std::string("\n\n");
  }
  
  AllowedArgs::AllowedArgs(bool permit_unrecognized) : m_permit_unrecognized(permit_unrecognized) {}
  AllowedArgs &AllowedArgs::addHeader(const std::string &strHeader, bool debug)
  {
      m_helpList.push_back(HelpComponent{strHeader + "\n\n", debug});
      return *this;
  }
  
  AllowedArgs &AllowedArgs::addDebugArg(const std::string &strArgsDefinition,
      CheckValueFunc checkValueFunc,
      const std::string &strHelp)
  {
      return addArg(strArgsDefinition, checkValueFunc, strHelp, true);
  }
  
  AllowedArgs &AllowedArgs::addArg(const std::string &strArgsDefinition,
      CheckValueFunc checkValueFunc,
      const std::string &strHelp,
      bool debug)
  {
      std::string strArgs = strArgsDefinition;
      std::string strExampleValue;
      size_t is_index = strArgs
  
  [... the rest is omitted ...]
files: src/allowed_args.cpp
files: // Copyright (c) 2009-2010 Satoshi Nakamoto
  // Copyright (c) 2009-2015 The Bitcoin Core developers
  // Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #ifndef BITCOIN_INIT_H
  #define BITCOIN_INIT_H
  
  #include <string>
  
  class CScheduler;
  class CWallet;
  
  namespace boost
  {
  class thread_group;
  } // namespace boost
  
  void StartShutdown();
  bool ShutdownRequested();
  /** Interrupt threads */
  void Interrupt(boost::thread_group& threadGroup);
  void Shutdown();
  //!Initialize the logging infrastructure
  void InitLogging();
  //!Parameter interaction: change current parameters depending on various rules
  void InitParameterInteraction();
  bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler);
  
  void MainCleanup();
  void NetCleanup();
  
  static const bool DEFAULT_PROXYRANDOMIZE = true;
  static const bool DEFAULT_REST_ENABLE = false;
  static const bool DEFAULT_DISABLE_SAFEMODE = false;
  static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
  static const bool DEFAULT_PV_TESTMODE = false;
  
  /** Returns licensing information (for -version) */
  std::string LicenseInfo();
  
  #endif // BITCOIN_INIT_H
  
  
  [... the rest is omitted ...]
files: src/init.h
files: // Copyright (c) 2009-2010 Satoshi Nakamoto
  // Copyright (c) 2009-2015 The Bitcoin Core developers
  // Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #ifndef BITCOIN_INIT_H
  #define BITCOIN_INIT_H
  
  #include <string>
  
  class CScheduler;
  class CWallet;
  
  namespace boost
  {
  class thread_group;
  } // namespace boost
  
  void StartShutdown();
  bool ShutdownRequested();
  /** Interrupt threads */
  void Interrupt(boost::thread_group& threadGroup);
  void Shutdown();
  //!Initialize the logging infrastructure
  void InitLogging();
  //!Parameter interaction: change current parameters depending on various rules
  void InitParameterInteraction();
  bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler);
  
  void MainCleanup();
  void NetCleanup();
  
  static const bool DEFAULT_PROXYRANDOMIZE = true;
  static const bool DEFAULT_REST_ENABLE = false;
  static const bool DEFAULT_DISABLE_SAFEMODE = false;
  static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
  
  /** Returns licensing information (for -version) */
  std::string LicenseInfo();
  
  #endif // BITCOIN_INIT_H
  
  
  [... the rest is omitted ...]
files: src/init.h
files: // Copyright (c) 2009-2010 Satoshi Nakamoto
  // Copyright (c) 2009-2015 The Bitcoin Core developers
  // Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  // Copyright (c) 2016 Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include "main.h"
  
  #include "addrman.h"
  #include "arith_uint256.h"
  #include "chainparams.h"
  #include "checkpoints.h"
  #include "checkqueue.h"
  #include "connmgr.h"
  #include "consensus/consensus.h"
  #include "consensus/merkle.h"
  #include "consensus/validation.h"
  #include "dosman.h"
  #include "expedited.h"
  #include "hash.h"
  #include "init.h"
  #include "merkleblock.h"
  #include "net.h"
  #include "nodestate.h"
  #include "parallel.h"
  #include "policy/policy.h"
  #include "pow.h"
  #include "primitives/block.h"
  #include "primitives/transaction.h"
  #include "requestManager.h"
  #include "script/script.h"
  #include "script/sigcache.h"
  #include "script/standard.h"
  #include "thinblock.h"
  #include "tinyformat.h"
  #include "txdb.h"
  #include "txmempool.h"
  #include "ui_interface.h"
  #include "undo.h"
  #include "util.h"
  #include "utilmoneystr.h"
  #include "utilstrencodings.h"
  #include "validationinterface.h"
  #include "versionbits.h"
  
  #include <algorithm>
  #include <boost/algorithm/hex.hpp>
  #include <boost/algorithm/string/replace.hpp>
  #include <boost/filesystem.hpp>
  #include <boost/filesystem/fstream.hpp>
  #include <boost/math/distributions/poisson.hpp>
  #include <boost/scope_exit.hpp>
  #include <boost/thread.hpp>
  #include <sstream>
  
  #if defined(NDEBUG)
  #error "Bitcoin cannot be compiled without assertions."
  #endif
  
  /**
   * Global state
   */
  
  // BU variables moved to globals.cpp
  // BU moved CCriticalSection cs_main;
  
  // BU moved BlockMap mapBlockIndex;
  // BU movedCChain chainActive;
  CBlockIndex *pindexBestHeader = NULL;
  int64_t nTimeBestReceived = 0;
  // BU moved CWaitableCriticalSection csBestBlock;
  // BU moved CConditionVariable cvBlockChange;
  bool fImporting = false;
  bool fReindex = false;
  bool fTxIndex = false;
  bool fHavePruned = false;
  bool fPruneMode = false;
  bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
  bool fRequireStandard = true;
  unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
  bool fCheckBlockIndex = false;
  bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
  size_t nCoinCacheUsage = 5000 * 300;
  uint64_t nPruneTarget = 0;
  
  CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
  
  // BU: Move global objects to a single file
  extern CTxMemPool mempool;
  
  // BU: change locking of orphan map from using cs_main to cs_orphancache.
  // There is too much dependance on cs_main locks which are generally too
  // broad in scope.
  // Move globals to a single file
  extern CCriticalSection cs_orphancache;
  extern std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(cs_orphancache);
  extern std::map<uint256, std::set<uint256> > mapOrphanTransactionsByPrev GUARDED
  
  [... the rest is omitted ...]
files: src/main.cpp
files: // Copyright (c) 2009-2010 Satoshi Nakamoto
  // Copyright (c) 2009-2015 The Bitcoin Core developers
  // Copyright (c) 2015-2017 The Bitcoin Unlimited developers
  // Copyright (c) 2016 Bitcoin Unlimited developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include "main.h"
  
  #include "addrman.h"
  #include "arith_uint256.h"
  #include "chainparams.h"
  #include "checkpoints.h"
  #include "checkqueue.h"
  #include "connmgr.h"
  #include "consensus/consensus.h"
  #include "consensus/merkle.h"
  #include "consensus/validation.h"
  #include "dosman.h"
  #include "expedited.h"
  #include "hash.h"
  #include "init.h"
  #include "merkleblock.h"
  #include "net.h"
  #include "nodestate.h"
  #include "parallel.h"
  #include "policy/policy.h"
  #include "pow.h"
  #include "primitives/block.h"
  #include "primitives/transaction.h"
  #include "requestManager.h"
  #include "script/script.h"
  #include "script/sigcache.h"
  #include "script/standard.h"
  #include "thinblock.h"
  #include "tinyformat.h"
  #include "txdb.h"
  #include "txmempool.h"
  #include "ui_interface.h"
  #include "undo.h"
  #include "util.h"
  #include "utilmoneystr.h"
  #include "utilstrencodings.h"
  #include "validationinterface.h"
  #include "versionbits.h"
  
  #include <algorithm>
  #include <boost/algorithm/hex.hpp>
  #include <boost/algorithm/string/replace.hpp>
  #include <boost/filesystem.hpp>
  #include <boost/filesystem/fstream.hpp>
  #include <boost/math/distributions/poisson.hpp>
  #include <boost/scope_exit.hpp>
  #include <boost/thread.hpp>
  #include <sstream>
  
  #if defined(NDEBUG)
  #error "Bitcoin cannot be compiled without assertions."
  #endif
  
  /**
   * Global state
   */
  
  // BU variables moved to globals.cpp
  // BU moved CCriticalSection cs_main;
  
  // BU moved BlockMap mapBlockIndex;
  // BU movedCChain chainActive;
  CBlockIndex *pindexBestHeader = NULL;
  int64_t nTimeBestReceived = 0;
  // BU moved CWaitableCriticalSection csBestBlock;
  // BU moved CConditionVariable cvBlockChange;
  bool fImporting = false;
  bool fReindex = false;
  bool fTxIndex = false;
  bool fHavePruned = false;
  bool fPruneMode = false;
  bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
  bool fRequireStandard = true;
  unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
  bool fCheckBlockIndex = false;
  bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
  size_t nCoinCacheUsage = 5000 * 300;
  uint64_t nPruneTarget = 0;
  
  CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
  
  // BU: Move global objects to a single file
  extern CTxMemPool mempool;
  
  // BU: change locking of orphan map from using cs_main to cs_orphancache.
  // There is too much dependance on cs_main locks which are generally too
  // broad in scope.
  // Move globals to a single file
  extern CCriticalSection cs_orphancache;
  extern std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(cs_orphancache);
  extern std::map<uint256, std::set<uint256> > mapOrphanTransactionsByPrev GUARDED
  
  [... the rest is omitted ...]
files: src/main.cpp