39 namespace bpo = boost::program_options;
41 debug_witness_plugin::~debug_witness_plugin()
46 void debug_witness_plugin::plugin_set_program_options(
47 boost::program_options::options_description& command_line_options,
48 boost::program_options::options_description& config_file_options)
51 command_line_options.add_options()
52 (
"debug-private-key", bpo::value<vector<string>>()->composing()->multitoken()->
54 "Tuple of [PublicKey, WIF private key] (may specify multiple times)");
55 config_file_options.add(command_line_options);
58 std::string debug_witness_plugin::plugin_name()
const
60 return "debug_witness";
63 void debug_witness_plugin::plugin_initialize(
const boost::program_options::variables_map& options)
65 ilog(
"debug_witness plugin: plugin_initialize() begin");
68 if( options.count(
"debug-private-key") > 0 )
70 const std::vector<std::string> key_id_to_wif_pair_strings = options[
"debug-private-key"].as<std::vector<std::string>>();
71 for (
const std::string& key_id_to_wif_pair_string : key_id_to_wif_pair_strings)
73 auto key_id_to_wif_pair = graphene::app::dejsonify<std::pair<chain::public_key_type, std::string> >(key_id_to_wif_pair_string,
GRAPHENE_MAX_NESTED_OBJECTS);
74 idump((key_id_to_wif_pair));
86 FC_THROW(
"Invalid WIF-format private key ${key_string}", (
"key_string", key_id_to_wif_pair.second));
89 _private_keys[key_id_to_wif_pair.first] = *private_key;
92 ilog(
"debug_witness plugin: plugin_initialize() end");
95 void debug_witness_plugin::plugin_startup()
97 ilog(
"debug_witness_plugin::plugin_startup() begin");
103 _changed_objects_conn = db.
changed_objects.connect([
this](
const std::vector<graphene::db::object_id_type>& ids,
const fc::flat_set<graphene::chain::account_id_type>& impacted_accounts){ on_changed_objects(ids, impacted_accounts); });
104 _removed_objects_conn = db.
removed_objects.connect([
this](
const std::vector<graphene::db::object_id_type>& ids,
const std::vector<const graphene::db::object*>& objs,
const fc::flat_set<graphene::chain::account_id_type>& impacted_accounts){ on_removed_objects(ids, objs, impacted_accounts); });
108 void debug_witness_plugin::on_changed_objects(
const std::vector<graphene::db::object_id_type>& ids,
const fc::flat_set<graphene::chain::account_id_type>& impacted_accounts )
110 if( _json_object_stream && (ids.size() > 0) )
124 void debug_witness_plugin::on_removed_objects(
const std::vector<graphene::db::object_id_type>& ids,
const std::vector<const graphene::db::object*> objs,
const fc::flat_set<graphene::chain::account_id_type>& impacted_accounts )
126 if( _json_object_stream )
137 if( _json_object_stream )
143 void debug_witness_plugin::set_json_object_stream(
const std::string& filename )
145 if( _json_object_stream )
147 _json_object_stream->close();
148 _json_object_stream.reset();
150 _json_object_stream = std::make_shared< std::ofstream >( filename );
153 void debug_witness_plugin::flush_json_object_stream()
155 if( _json_object_stream )
156 _json_object_stream->flush();
159 void debug_witness_plugin::plugin_shutdown()
164 void debug_witness_plugin::cleanup()
166 if( _json_object_stream )
168 _json_object_stream->close();
169 _json_object_stream.reset();