github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/cmd/naxer/main.cpp (about)

     1  // Copyright (C) 2018 go-nebulas authors
     2  //
     3  // This file is part of the go-nebulas library.
     4  //
     5  // the go-nebulas library is free software: you can redistribute it and/or
     6  // modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // the go-nebulas library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with the go-nebulas library.  If not, see
    18  // <http://www.gnu.org/licenses/>.
    19  //
    20  
    21  #include "common/configuration.h"
    22  #include "common/ir_conf_reader.h"
    23  #include "core/ir_warden.h"
    24  #include "jit/jit_driver.h"
    25  #include <boost/program_options.hpp>
    26  
    27  namespace po = boost::program_options;
    28  
    29  int main(int argc, char *argv[]) {
    30    po::options_description desc("Rocksdb read and write");
    31    desc.add_options()("help", "show help message")(
    32        "module", po::value<std::string>(),
    33        "Module name")("func", po::value<std::string>(), "function name")(
    34        "height", po::value<neb::block_height_t>(), "block height");
    35  
    36    po::variables_map vm;
    37    po::store(po::parse_command_line(argc, argv, desc), vm);
    38    po::notify(vm);
    39  
    40    if (vm.count("help")) {
    41      std::cout << desc << "\n";
    42      return 1;
    43    }
    44  
    45    if (!vm.count("module")) {
    46      std::cout << "You must specify \"module\"!" << std::endl;
    47      return 1;
    48    }
    49    if (!vm.count("height")) {
    50      std::cout << "You must specify \"height\"!" << std::endl;
    51      return 1;
    52    }
    53  
    54    // naxer --module nr --height 1000
    55  
    56    neb::core::ir_warden::instance().on_timer();
    57    neb::core::ir_warden::instance().wait_until_sync();
    58  
    59    std::string module = vm["module"].as<std::string>();
    60    neb::block_height_t height = vm["height"].as<neb::block_height_t>();
    61    auto irs =
    62        neb::core::ir_warden::instance().get_ir_by_name_height(module, height);
    63  
    64    neb::jit_driver &jd = neb::jit_driver::instance();
    65    jd.run_ir<int, neb::core::driver *, void *>(
    66        module, height, vm["func"].as<std::string>(), nullptr, nullptr);
    67    // jd.run(nullptr, irs, vm["func"].as<std::string>(), nullptr);
    68  }