github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/cmd/nr/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/version.h"
    22  #include "runtime/nr/impl/nebulas_rank.h"
    23  #include "runtime/nr/impl/nr_impl.h"
    24  #include <boost/program_options.hpp>
    25  
    26  namespace po = boost::program_options;
    27  
    28  int main(int argc, char *argv[]) {
    29  
    30    int64_t a = 3118;
    31    int64_t b = 3792;
    32    int64_t c = 6034;
    33    int64_t d = 4158;
    34    neb::rt::nr::nr_float_t theta = 2.2;
    35    neb::rt::nr::nr_float_t mu = 0.1;
    36    neb::rt::nr::nr_float_t lambda = 0.3;
    37  
    38    po::options_description desc("Nr");
    39    desc.add_options()("help", "show help message")(
    40        "start_block", po::value<uint64_t>(), "Start block height")(
    41        "end_block", po::value<uint64_t>(), "End block height");
    42  
    43    po::variables_map vm;
    44    po::store(po::parse_command_line(argc, argv, desc), vm);
    45    po::notify(vm);
    46  
    47    if (vm.count("help")) {
    48      std::cout << desc << "\n";
    49      return 1;
    50    }
    51  
    52    if (!vm.count("start_block")) {
    53      std::cout << "You must specify \"start_block\"!" << std::endl;
    54      return 1;
    55    }
    56    if (!vm.count("end_block")) {
    57      std::cout << "You must specify \"end_block\"!" << std::endl;
    58      return 1;
    59    }
    60  
    61    uint64_t start_block = vm["start_block"].as<uint64_t>();
    62    uint64_t end_block = vm["end_block"].as<uint64_t>();
    63    auto nr_ret = neb::rt::nr::entry_point_nr_impl(start_block, end_block,
    64                                                   neb::version(0, 1, 0).data(),
    65                                                   a, b, c, d, theta, mu, lambda);
    66    // std::cout << ret << std::endl;
    67    // std::cout << std::endl;
    68  
    69    if (std::get<0>(nr_ret)) {
    70      auto ret = neb::rt::nr::nebulas_rank::nr_info_to_json(nr_ret);
    71      std::cout << *ret << std::endl;
    72    }
    73    return 0;
    74  }