mining.h raw

   1  // Copyright (c) 2019-2021 The Limenka developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  
   5  #ifndef LIMENKA_TEST_UTIL_MINING_H
   6  #define LIMENKA_TEST_UTIL_MINING_H
   7  
   8  #include <node/miner.h>
   9  
  10  #include <memory>
  11  #include <string>
  12  #include <vector>
  13  
  14  class CBlock;
  15  class CChainParams;
  16  class COutPoint;
  17  class CScript;
  18  namespace node {
  19  struct NodeContext;
  20  } // namespace node
  21  
  22  /** Create a blockchain, starting from genesis */
  23  std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const CChainParams& params);
  24  
  25  /** Returns the generated coin */
  26  COutPoint MineBlock(const node::NodeContext&,
  27                      const node::BlockAssembler::Options& assembler_options);
  28  
  29  /**
  30   * Returns the generated coin (or Null if the block was invalid).
  31   * It is recommended to call RegenerateCommitments before mining the block to avoid merkle tree mismatches.
  32   **/
  33  COutPoint MineBlock(const node::NodeContext&, std::shared_ptr<CBlock>& block);
  34  
  35  /** Prepare a block to be mined */
  36  std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext&);
  37  std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext& node,
  38                                       const node::BlockAssembler::Options& assembler_options);
  39  
  40  /** RPC-like helper function, returns the generated coin */
  41  COutPoint generatetoaddress(const node::NodeContext&, const std::string& address);
  42  
  43  #endif // LIMENKA_TEST_UTIL_MINING_H
  44