Skip to content

Commit

Permalink
Merge pull request steemit#525 from GolosChain/493-config-load-save
Browse files Browse the repository at this point in the history
Fix golosd config processing issues steemit#493
  • Loading branch information
kotbegemot committed Apr 9, 2018
2 parents c768f0b + 673b991 commit baf7430
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 91 deletions.
29 changes: 14 additions & 15 deletions plugins/chain/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace chain {
"block-num-check-free-size", boost::program_options::value<uint32_t>()->default_value(1000),
"Check free space in shared memory each N blocks. Default: 1000 (each 3000 seconds)."
) (
"checkpoint,c", boost::program_options::value<std::vector<std::string>>()->composing(),
"checkpoint", boost::program_options::value<std::vector<std::string>>()->composing(),
"Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints."
) (
"flush-state-interval", boost::program_options::value<uint32_t>(),
Expand Down Expand Up @@ -201,15 +201,12 @@ namespace chain {
void plugin::plugin_initialize(const boost::program_options::variables_map &options) {

my.reset(new plugin_impl());
my->shared_memory_dir = appbase::app().data_dir() / "blockchain";

if (options.count("shared-file-dir")) {
auto sfd = options.at("shared-file-dir").as<boost::filesystem::path>();
if (sfd.is_relative()) {
my->shared_memory_dir = appbase::app().data_dir() / sfd;
} else {
my->shared_memory_dir = sfd;
}

auto sfd = options.at("shared-file-dir").as<boost::filesystem::path>();
if (sfd.is_relative()) {
my->shared_memory_dir = appbase::app().data_dir() / sfd;
} else {
my->shared_memory_dir = sfd;
}

if (options.count("read-wait-micro")) {
Expand Down Expand Up @@ -261,9 +258,11 @@ namespace chain {
void plugin::plugin_startup() {
ilog("Starting chain with shared_file_size: ${n} bytes", ("n", my->shared_memory_size));

auto data_dir = appbase::app().data_dir() / "blockchain";

if (my->resync) {
wlog("resync requested: deleting block log and shared memory");
my->db.wipe(appbase::app().data_dir() / "blockchain", my->shared_memory_dir, true);
my->db.wipe(data_dir, my->shared_memory_dir, true);
}

my->db.set_flush_interval(my->flush_interval);
Expand All @@ -284,19 +283,19 @@ namespace chain {

if (my->replay) {
ilog("Replaying blockchain on user request.");
my->db.reindex(appbase::app().data_dir() / "blockchain", my->shared_memory_dir, my->shared_memory_size);
my->db.reindex(data_dir, my->shared_memory_dir, my->shared_memory_size);
} else {
try {
ilog("Opening shared memory from ${path}", ("path", my->shared_memory_dir.generic_string()));
my->db.open(appbase::app().data_dir() / "blockchain", my->shared_memory_dir, STEEMIT_INIT_SUPPLY, my->shared_memory_size, chainbase::database::read_write/*, my->validate_invariants*/ );
my->db.open(data_dir, my->shared_memory_dir, STEEMIT_INIT_SUPPLY, my->shared_memory_size, chainbase::database::read_write/*, my->validate_invariants*/ );
} catch (const fc::exception &e) {
wlog("Error opening database, attempting to replay blockchain. Error: ${e}", ("e", e));

try {
my->db.reindex(appbase::app().data_dir() / "blockchain", my->shared_memory_dir, my->shared_memory_size);
my->db.reindex(data_dir, my->shared_memory_dir, my->shared_memory_size);
} catch (golos::chain::block_log &) {
wlog("Error opening block log. Having to resync from network...");
my->db.open(appbase::app().data_dir() / "blockchain", my->shared_memory_dir, STEEMIT_INIT_SUPPLY, my->shared_memory_size, chainbase::database::read_write/*, my->validate_invariants*/ );
my->db.open(data_dir, my->shared_memory_dir, STEEMIT_INIT_SUPPLY, my->shared_memory_size, chainbase::database::read_write/*, my->validate_invariants*/ );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/debug_node/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void plugin::set_program_options (
boost::program_options::options_description &cli,
boost::program_options::options_description &cfg
) {
cfg.add_options()
cli.add_options()
("debug-node-edit-script,e",
boost::program_options::value< std::vector< std::string > >()->composing(),
"Database edits to apply on startup (may specify multiple times)")
"Database edits to apply on startup (may specify multiple times)")
("edit-script", boost::program_options::value< std::vector< std::string > >()->composing(),
"Database edits to apply on startup (may specify multiple times). Deprecated in favor of debug-node-edit-script.")
"Database edits to apply on startup (may specify multiple times). Deprecated in favor of debug-node-edit-script.")
;
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/follow/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ namespace golos {
void plugin::set_program_options(boost::program_options::options_description &cli,
boost::program_options::options_description &cfg) {
cli.add_options()("follow-max-feed-size", boost::program_options::value<uint32_t>()->default_value(500),
"Set the maximum size of cached feed for an account");
cli.add_options()
("follow-max-feed-size", boost::program_options::value<uint32_t>()->default_value(500),
"Set the maximum size of cached feed for an account");
cfg.add(cli);
}
Expand Down
22 changes: 12 additions & 10 deletions plugins/p2p/p2p_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,19 @@ namespace golos {
}

void p2p_plugin::set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) {
cfg.add_options()("p2p-endpoint", boost::program_options::value<string>()->implicit_value("127.0.0.1:9876"),
"The local IP address and port to listen for incoming connections.")(
"p2p-max-connections", boost::program_options::value<uint32_t>(),
"Maxmimum number of incoming connections on P2P endpoint.")("seed-node", boost::program_options::value<
vector<string>>()->composing(),
"The IP address and port of a remote peer to sync with. Deprecated in favor of p2p-seed-node.")(
"p2p-seed-node", boost::program_options::value<vector<string>>()->composing(),
cfg.add_options()
("p2p-endpoint", boost::program_options::value<string>()->implicit_value("127.0.0.1:9876"),
"The local IP address and port to listen for incoming connections.")
("p2p-max-connections", boost::program_options::value<uint32_t>(),
"Maxmimum number of incoming connections on P2P endpoint.")
("seed-node", boost::program_options::value<vector<string>>()->composing(),
"The IP address and port of a remote peer to sync with. Deprecated in favor of p2p-seed-node.")
("p2p-seed-node", boost::program_options::value<vector<string>>()->composing(),
"The IP address and port of a remote peer to sync with.");
cli.add_options()("force-validate", boost::program_options::bool_switch()->default_value(false),
"Force validation of all transactions. Deprecated in favor of p2p-force-validate")(
"p2p-force-validate", boost::program_options::bool_switch()->default_value(false),
cli.add_options()
("force-validate", boost::program_options::bool_switch()->default_value(false),
"Force validation of all transactions. Deprecated in favor of p2p-force-validate")
("p2p-force-validate", boost::program_options::bool_switch()->default_value(false),
"Force validation of all transactions.");
}

Expand Down
15 changes: 8 additions & 7 deletions plugins/webserver/webserver_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ namespace golos {
}

void webserver_plugin::set_program_options(boost::program_options::options_description &, boost::program_options::options_description &cfg) {
cfg.add_options()("webserver-http-endpoint", boost::program_options::value<string>(),
"Local http endpoint for webserver requests.")("webserver-ws-endpoint",
boost::program_options::value<string>(),
"Local websocket endpoint for webserver requests.")(
"rpc-endpoint", boost::program_options::value<string>(),
"Local http and websocket endpoint for webserver requests. Deprectaed in favor of webserver-http-endpoint and webserver-ws-endpoint")(
"webserver-thread-pool-size", boost::program_options::value<thread_pool_size_t>()->default_value(256),
cfg.add_options()
("webserver-http-endpoint", boost::program_options::value<string>(),
"Local http endpoint for webserver requests.")
("webserver-ws-endpoint", boost::program_options::value<string>(),
"Local websocket endpoint for webserver requests.")
("rpc-endpoint", boost::program_options::value<string>(),
"Local http and websocket endpoint for webserver requests. Deprectaed in favor of webserver-http-endpoint and webserver-ws-endpoint")
("webserver-thread-pool-size", boost::program_options::value<thread_pool_size_t>()->default_value(256),
"Number of threads used to handle queries. Default: 256.");
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/witness/witness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace golos {
string witness_id_example = "initwitness";

command_line_options.add_options()
("enable-stale-production", bpo::value<bool>()->implicit_value(false) , "Enable block production, even if the chain is stale.")
("enable-stale-production", bpo::value<bool>()->implicit_value(false) , "Enable block production, even if the chain is stale.")
("required-participation", bpo::value<int>()->implicit_value(uint32_t(3 * STEEMIT_1_PERCENT)), "Percent of witnesses (0-99) that must be participating in order to produce blocks")
("witness,w", bpo::value<vector<string>>()->composing()->multitoken(), ("name of witness controlled by this node (e.g. " + witness_id_example + " )").c_str())
("miner,m", bpo::value<vector<string>>()->composing()->multitoken(), "name of miner and its private key (e.g. [\"account\",\"WIF PRIVATE KEY\"] )")
Expand Down
Loading

0 comments on commit baf7430

Please sign in to comment.