github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/runtime/dip/dip_reward.h (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 #pragma once 22 23 #include "common/address.h" 24 #include "runtime/nr/impl/nebulas_rank.h" 25 #include "runtime/nr/impl/nr_handler.h" 26 27 namespace neb { 28 namespace rt { 29 namespace dip { 30 31 struct dip_info_t { 32 address_t m_deployer; 33 address_t m_contract; 34 std::string m_reward; 35 }; 36 37 using nr_info_t = ::neb::rt::nr::nr_info_t; 38 using dip_ret_type = 39 std::tuple<int32_t, std::string, std::vector<std::shared_ptr<dip_info_t>>, 40 nr::nr_ret_type>; 41 42 class dip_reward { 43 public: 44 static auto 45 get_dip_reward(neb::block_height_t start_block, neb::block_height_t end_block, 46 neb::block_height_t height, 47 const std::vector<std::shared_ptr<nr::nr_info_t>> &nr_result, 48 const neb::rt::nr::transaction_db_ptr_t &tdb_ptr, 49 const neb::rt::nr::account_db_ptr_t &adb_ptr, floatxx_t alpha, 50 floatxx_t beta) -> std::vector<std::shared_ptr<dip_info_t>>; 51 52 static str_uptr_t dip_info_to_json(const dip_ret_type &dip_ret); 53 static dip_ret_type json_to_dip_info(const std::string &dip_reward); 54 55 #ifdef Release 56 private: 57 #else 58 public: 59 #endif 60 static auto account_call_contract_count( 61 const std::vector<neb::fs::transaction_info_t> &txs) 62 -> std::unique_ptr<std::unordered_map< 63 address_t, std::unordered_map<address_t, uint32_t>>>; 64 65 static auto account_to_contract_votes( 66 const std::vector<neb::fs::transaction_info_t> &txs, 67 const std::vector<std::shared_ptr<neb::rt::nr::nr_info_t>> &nr_infos) 68 -> std::unique_ptr<std::unordered_map< 69 address_t, std::unordered_map<address_t, floatxx_t>>>; 70 71 static auto 72 dapp_votes(const std::unordered_map<address_t, 73 std::unordered_map<address_t, floatxx_t>> 74 &acc_contract_votes) 75 -> std::unique_ptr<std::unordered_map<address_t, floatxx_t>>; 76 77 static floatxx_t participate_lambda( 78 floatxx_t alpha, floatxx_t beta, 79 const std::vector<neb::fs::transaction_info_t> &txs, 80 const std::vector<std::shared_ptr<neb::rt::nr::nr_info_t>> &nr_infos); 81 82 static void full_fill_meta_info( 83 const std::vector<std::pair<std::string, std::string>> &meta, 84 boost::property_tree::ptree &root); 85 86 static void 87 back_to_coinbase(std::vector<std::shared_ptr<dip_info_t>> &dip_infos, 88 floatxx_t reward_left, const address_t &coinbase_addr); 89 90 static void ignore_account_transfer_contract( 91 std::vector<neb::fs::transaction_info_t> &txs, 92 const std::string &tx_type); 93 }; 94 95 } // namespace dip 96 } // namespace rt 97 } // namespace neb