github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/cmd/dummy_neb/dummy_callback.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 #include "cmd/dummy_neb/dummy_callback.h" 21 22 callback_handler::callback_handler() {} 23 24 void callback_handler::handle_version(void *holder, uint32_t major, 25 uint32_t minor, uint32_t patch) { 26 handle(m_version_handlers, holder, major, minor, patch); 27 } 28 void callback_handler::handle_ir_list(void *holder, const char *ir_name_list) { 29 handle(m_ir_list_handlers, holder, ir_name_list); 30 } 31 void callback_handler::handle_ir_versions(void *holder, 32 const char *ir_versions) { 33 handle(m_ir_versions_handlers, holder, ir_versions); 34 } 35 void callback_handler::handle_nr(void *holder, const char *nr_handler_id) { 36 handle(m_nr_handlers, holder, nr_handler_id); 37 } 38 void callback_handler::handle_nr_result(void *holder, const char *nr_result) { 39 handle(m_nr_result_handlers, holder, nr_result); 40 } 41 void callback_handler::handle_nr_result_by_height(void *holder, 42 const char *nr_result) { 43 handle(m_nr_result_by_height_handlers, holder, nr_result); 44 } 45 void callback_handler::handle_nr_sum(void *holder, const char *nr_sum) { 46 handle(m_nr_sum_handlers, holder, nr_sum); 47 } 48 void callback_handler::handle_dip_reward(void *holder, const char *dip_reward) { 49 handle(m_dip_reward_handlers, holder, dip_reward); 50 } 51 52 void nbre_version_callback(ipc_status_code isc, void *handler, uint32_t major, 53 uint32_t minor, uint32_t patch) { 54 if (isc != ipc_status_succ) { 55 LOG(ERROR) << "nbre_version_call_back got failed "; 56 return; 57 } 58 callback_handler::instance().handle_version(handler, major, minor, patch); 59 } 60 61 void nbre_ir_list_callback(ipc_status_code isc, void *handler, 62 const char *ir_name_list) { 63 if (isc != ipc_status_succ) { 64 LOG(ERROR) << "nbre_ir_list_callback got failed "; 65 return; 66 } 67 callback_handler::instance().handle_ir_list(handler, ir_name_list); 68 } 69 void nbre_ir_versions_callback(ipc_status_code isc, void *handler, 70 const char *ir_versions) { 71 if (isc != ipc_status_succ) { 72 LOG(ERROR) << "nbre_ir_versions_callback got failed "; 73 return; 74 } 75 callback_handler::instance().handle_ir_versions(handler, ir_versions); 76 } 77 78 void nbre_nr_handle_callback(ipc_status_code isc, void *holder, 79 const char *nr_handle_id) { 80 if (isc != ipc_status_succ) { 81 LOG(ERROR) << "nbre_nr_handle_callback got failed "; 82 return; 83 } 84 callback_handler::instance().handle_nr(holder, nr_handle_id); 85 } 86 87 void nbre_nr_result_callback(ipc_status_code isc, void *holder, 88 const char *nr_result) { 89 if (isc != ipc_status_succ) { 90 LOG(ERROR) << "nbre_nr_result_callback got failed "; 91 return; 92 } 93 callback_handler::instance().handle_nr_result(holder, nr_result); 94 } 95 96 void nbre_nr_result_by_height_callback(ipc_status_code isc, void *holder, 97 const char *nr_result) { 98 if (isc != ipc_status_succ) { 99 LOG(ERROR) << "nbre_nr_result_by_height_callback got failed "; 100 return; 101 } 102 callback_handler::instance().handle_nr_result_by_height(holder, nr_result); 103 } 104 105 void nbre_nr_sum_callback(ipc_status_code isc, void *holder, 106 const char *nr_sum) { 107 if (isc != ipc_status_succ) { 108 LOG(ERROR) << "nbre_nr_sum_callback got failed "; 109 return; 110 } 111 callback_handler::instance().handle_nr_sum(holder, nr_sum); 112 } 113 114 void nbre_dip_reward_callback(ipc_status_code isc, void *holder, 115 const char *dip_reward) { 116 if (isc != ipc_status_succ) { 117 LOG(ERROR) << "nbre_dip_reward_callback got failed "; 118 return; 119 } 120 callback_handler::instance().handle_dip_reward(holder, dip_reward); 121 } 122