github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/ir/dip/dip_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/dip/dip_impl.h" 22 23 extern neb::rt::nr::nr_ret_type 24 entry_point_nr(neb::compatible_uint64_t start_block, 25 neb::compatible_uint64_t end_block); 26 27 neb::rt::dip::dip_ret_type entry_point_dip(neb::compatible_uint64_t height) { 28 29 neb::rt::dip::dip_ret_type ret; 30 std::get<0>(ret) = 0; 31 32 uint64_t block_nums_of_a_day = 24 * 3600 / 15; 33 uint64_t days = 7; 34 neb::compatible_uint64_t dip_start_block = 1562800; 35 neb::compatible_uint64_t dip_block_interval = days * block_nums_of_a_day; 36 std::string dip_reward_addr = 37 std::string("n1c6y4ctkMeZk624QWBTXuywmNpCWmJZiBq"); 38 std::string coinbase_addr = 39 std::string("n1EzGmFsVepKduN1U5QFyhLqpzFvM9sRSmG"); 40 41 auto to_version_t = [](uint32_t major_version, uint16_t minor_version, 42 uint16_t patch_version) -> neb::rt::dip::version_t { 43 return (0ULL + major_version) + ((0ULL + minor_version) << 32) + 44 ((0ULL + patch_version) << 48); 45 }; 46 47 if (!height) { 48 std::get<1>(ret) = neb::rt::dip::dip_param_list( 49 dip_start_block, dip_block_interval, dip_reward_addr, coinbase_addr, 50 to_version_t(0, 0, 1)); 51 return ret; 52 } 53 54 if (height < dip_start_block + dip_block_interval) { 55 std::get<1>(ret) = std::string("{\"err\":\"invalid height\"}"); 56 return ret; 57 } 58 59 uint64_t interval_nums = (height - dip_start_block) / dip_block_interval; 60 neb::compatible_uint64_t start_block = 61 dip_start_block + dip_block_interval * interval_nums; 62 neb::compatible_uint64_t end_block = start_block - 1; 63 start_block -= dip_block_interval; 64 65 auto nr_ret = entry_point_nr(start_block, end_block); 66 67 neb::rt::dip::dip_float_t alpha = 8e-3; 68 neb::rt::dip::dip_float_t beta = 1; 69 70 return neb::rt::dip::entry_point_dip_impl(start_block, end_block, 71 to_version_t(0, 0, 1), height, 72 nr_ret, alpha, beta); 73 }