8 #include <fc/io/buffered_iostream.hpp>
9 #include <fc/io/fstream.hpp>
10 #include <fc/io/json.hpp>
12 #include <fc/thread/future.hpp>
13 #include <fc/thread/mutex.hpp>
14 #include <fc/thread/scoped_lock.hpp>
16 #include <graphene/utilities/key_conversion.hpp>
23 namespace debug_node {
39 boost::program_options::options_description& cfg)
54 ilog(
"debug_node_plugin::plugin_startup() begin");
64 const std::string& debug_key, uint32_t count, uint32_t skip, uint32_t miss_blocks,
private_key_storage* key_storage)
71 auto& witness_svc = db.witness_service();
73 fc::optional<fc::ecc::private_key> debug_private_key;
77 debug_private_key = graphene::utilities::wif_to_key(debug_key);
78 FC_ASSERT(debug_private_key.valid());
79 debug_public_key = debug_private_key->get_public_key();
82 uint32_t slot = miss_blocks + 1,
produced = 0;
85 uint32_t new_slot = miss_blocks + 1;
93 wlog(
"scheduled key is: ${sk} dbg key is: ${dk}", (
"sk", scheduled_key)(
"dk", debug_public_key));
94 if (scheduled_key != debug_public_key)
97 wlog(
"Modified key for witness ${w}", (
"w", scheduled_witness_name));
100 db.modify(scheduled_witness,
108 debug_private_key.reset();
109 if (key_storage !=
nullptr)
111 if (!debug_private_key.valid())
114 elog(
"Skipping ${wit} because I don't know the private key", (
"wit", scheduled_witness_name));
116 FC_ASSERT(slot < miss_blocks + 50);
119 db.
generate_block(scheduled_time, scheduled_witness_name, *debug_private_key, skip);
128 const fc::time_point_sec& head_block_time,
129 bool generate_sparsely,
138 uint32_t new_blocks = 0;
140 if (generate_sparsely)
144 if (slots_to_miss > 1)
159 void debug_node_plugin::apply_debug_updates()
164 auto it = _debug_updates.find(head_id);
165 if (it == _debug_updates.end())
168 for (
auto&
update : it->second)
176 if (!_debug_updates.empty())
177 apply_debug_updates();
void register_api_factory(const std::string &name, std::function< fc::api_ptr(const api_context &)> factory)
application & app() const
chain::database & database()
tracks the blockchain state in an extensible manner
signed_block generate_block(const fc::time_point_sec when, const account_name_type &witness_owner, const fc::ecc::private_key &block_signing_private_key, uint32_t skip)
uint32_t get_slot_at_time(fc::time_point_sec when) const
time_point_sec head_block_time() const
account_name_type get_scheduled_witness(uint32_t slot_num) const
Get the witness scheduled for block production in a slot.
fc::signal< void(const signed_block &)> applied_block
block_id_type head_block_id() const
fc::time_point_sec get_slot_time(uint32_t slot_num) const
public_key_type signing_key
debug_node_plugin(application *app)
virtual void plugin_startup() override
Begin normal runtime operations.
uint32_t debug_generate_blocks_until(const std::string &debug_key, const fc::time_point_sec &head_block_time, bool generate_sparsely, uint32_t skip=scorum::chain::database::skip_nothing, private_key_storage *key_storage=nullptr)
virtual ~debug_node_plugin()
void debug_update(Lambda &&callback, uint32_t skip=scorum::chain::database::skip_nothing)
uint32_t debug_generate_blocks(const std::string &debug_key, uint32_t count, uint32_t skip=scorum::chain::database::skip_nothing, uint32_t miss_blocks=0, private_key_storage *key_storage=nullptr)
virtual void plugin_set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) override
Fill in command line parameters used by the plugin.
virtual std::string plugin_name() const override
virtual void plugin_initialize(const boost::program_options::variables_map &options) override
Perform early startup routines and register plugin indexes, callbacks, etc.
virtual void plugin_shutdown() override
Cleanly shut down the plugin.
virtual void maybe_get_private_key(fc::optional< fc::ecc::private_key > &result, const scorum::chain::public_key_type &pubkey, const std::string &account_name)=0
void update(fc::flat_map< uuid_type, bet_resolved_operation > &results, const bet_data &bet, asset income, uuid_type game_uuid, bet_resolve_kind kind)
fc::ripemd160 block_id_type
#define SCORUM_DEFINE_PLUGIN(plugin_name, plugin_class)