Add option for overwrite last hardfork
This commit is contained in:
parent
cb3302160b
commit
d6be9a176f
3 changed files with 29 additions and 0 deletions
|
|
@ -796,6 +796,11 @@ public:
|
|||
}
|
||||
|
||||
virtual fc::time_point_sec get_last_known_hardfork_time() override {
|
||||
if( _additional_test_hardfork > _chain_db->_hardfork_times[_chain_db->_hardfork_times.size() - 1] )
|
||||
{
|
||||
return _additional_test_hardfork;
|
||||
}
|
||||
|
||||
return _chain_db->_hardfork_times[_chain_db->_hardfork_times.size() - 1];
|
||||
}
|
||||
|
||||
|
|
@ -844,6 +849,11 @@ public:
|
|||
std::map<string, std::shared_ptr<abstract_plugin>> _available_plugins;
|
||||
|
||||
bool _is_finished_syncing = false;
|
||||
|
||||
// it's used only for testing. It should be deleted once testing
|
||||
// for non compatible witnesses is done
|
||||
fc::time_point_sec _additional_test_hardfork;
|
||||
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
|
@ -1006,6 +1016,10 @@ void graphene::app::application::add_available_plugin(std::shared_ptr<graphene::
|
|||
my->_available_plugins[p->plugin_name()] = p;
|
||||
}
|
||||
|
||||
void graphene::app::application::add_additional_hardfork(fc::time_point_sec hardfork) {
|
||||
my->_additional_test_hardfork = hardfork;
|
||||
}
|
||||
|
||||
void application::shutdown_plugins() {
|
||||
for (auto &entry : my->_active_plugins)
|
||||
entry.second->plugin_shutdown();
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ public:
|
|||
}
|
||||
std::shared_ptr<abstract_plugin> get_plugin(const string &name) const;
|
||||
|
||||
void add_additional_hardfork(fc::time_point_sec hardfork);
|
||||
|
||||
template <typename PluginType>
|
||||
std::shared_ptr<PluginType> get_plugin(const string &name) const {
|
||||
std::shared_ptr<abstract_plugin> abs_plugin = get_plugin(name);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ void witness_plugin::plugin_set_program_options(
|
|||
("ID of witness controlled by this node (e.g. " + witness_id_example + ", quotes are required, may specify multiple times)").c_str())
|
||||
("witness-ids,W", bpo::value<string>(),
|
||||
("IDs of multiple witnesses controlled by this node (e.g. [" + witness_id_example + ", " + witness_id_example2 + "], quotes are required)").c_str())
|
||||
("hardfork", bpo::value<string>())
|
||||
("private-key", bpo::value<vector<string>>()->composing()->multitoken()->
|
||||
DEFAULT_VALUE_VECTOR(std::make_pair(chain::public_key_type(default_priv_key.get_public_key()), graphene::utilities::key_to_wif(default_priv_key))),
|
||||
"Tuple of [PublicKey, WIF private key] (may specify multiple times)")
|
||||
|
|
@ -120,6 +121,18 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m
|
|||
_private_keys[key_id_to_wif_pair.first] = *private_key;
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.count("hardfork") )
|
||||
{
|
||||
if (options.count("hardfork") > 1 )
|
||||
{
|
||||
FC_THROW("Please define only one hardfork ahead for the witness");
|
||||
}
|
||||
|
||||
std::string hardfork_string = options["hardfork"].as<std::string>();
|
||||
app().add_additional_hardfork(fc::time_point_sec::from_iso_string(hardfork_string));
|
||||
}
|
||||
|
||||
ilog("witness plugin: plugin_initialize() end");
|
||||
} FC_LOG_AND_RETHROW() }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue