github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/ir/nr/nr_testnet_v1.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 "runtime/nr/impl/nr_impl.h" 22 23 neb::rt::nr::nr_ret_type entry_point_nr(neb::compatible_uint64_t start_block, 24 neb::compatible_uint64_t end_block) { 25 neb::rt::nr::nr_ret_type ret; 26 std::get<0>(ret) = 0; 27 if (start_block > end_block) { 28 std::get<1>(ret) = 29 std::string("{\"err\":\"start height must less than end height\"}"); 30 return ret; 31 } 32 uint64_t block_nums_of_a_day = 24 * 3600 / 15; 33 uint64_t days = 7; 34 uint64_t block_interval = days * block_nums_of_a_day; 35 if (start_block + block_interval < end_block) { 36 std::get<1>(ret) = 37 std::string("{\"err\":\"nr block interval out of range\"}"); 38 return ret; 39 } 40 41 auto to_version_t = [](uint32_t major_version, uint16_t minor_version, 42 uint16_t patch_version) -> neb::rt::nr::version_t { 43 return (0ULL + major_version) + ((0ULL + minor_version) << 32) + 44 ((0ULL + patch_version) << 48); 45 }; 46 47 neb::compatible_int64_t a = 100; 48 neb::compatible_int64_t b = 2; 49 neb::compatible_int64_t c = 6; 50 neb::compatible_int64_t d = -9; 51 neb::rt::nr::nr_float_t theta = 1; 52 neb::rt::nr::nr_float_t mu = 1; 53 neb::rt::nr::nr_float_t lambda = 2; 54 55 return neb::rt::nr::entry_point_nr_impl(start_block, end_block, 56 to_version_t(0, 0, 1), a, b, c, d, 57 theta, mu, lambda); 58 } 59