diff --git a/libraries/appbase b/libraries/appbase index 028da3b1e8a..024ec0da993 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 028da3b1e8ad612865676734c54db3f6197f338d +Subproject commit 024ec0da9931700f25a89e8d80e02f555fe1310a diff --git a/libraries/chain/block_log.cpp b/libraries/chain/block_log.cpp index 363fa565cdb..038776b4259 100644 --- a/libraries/chain/block_log.cpp +++ b/libraries/chain/block_log.cpp @@ -68,8 +68,10 @@ namespace eos { namespace chain { } block_log::~block_log() { - flush(); - my.reset(); + if (my) { + flush(); + my.reset(); + } } void block_log::open(const fc::path& file) { diff --git a/libraries/chain/chain_controller.cpp b/libraries/chain/chain_controller.cpp index b200ccbe152..ffcd4b2753e 100644 --- a/libraries/chain/chain_controller.cpp +++ b/libraries/chain/chain_controller.cpp @@ -939,8 +939,6 @@ void chain_controller::spinup_fork_db() fc::optional last_block = _block_log.read_head(); if(last_block.valid()) { _fork_db.start_block(*last_block); - idump((last_block->id())(last_block->block_num())); - idump((head_block_id())(head_block_num())); if (last_block->id() != head_block_id()) { FC_ASSERT(head_block_num() == 0, "last block ID does not match current chain state", ("last_block->id", last_block->id())("head_block_num",head_block_num())); diff --git a/plugins/chain_api_plugin/chain_api_plugin.cpp b/plugins/chain_api_plugin/chain_api_plugin.cpp index 974d14525b8..c899e609434 100644 --- a/plugins/chain_api_plugin/chain_api_plugin.cpp +++ b/plugins/chain_api_plugin/chain_api_plugin.cpp @@ -16,8 +16,7 @@ class chain_api_plugin_impl { }; -chain_api_plugin::chain_api_plugin() - :my(new chain_api_plugin_impl(app().get_plugin().chain())) {} +chain_api_plugin::chain_api_plugin(){} chain_api_plugin::~chain_api_plugin(){} void chain_api_plugin::set_program_options(options_description&, options_description&) {} @@ -43,6 +42,7 @@ void chain_api_plugin::plugin_initialize(const variables_map&) {} #define CHAIN_RW_CALL(call_name) CALL(chain, rw_api, chain_apis::read_write, call_name) void chain_api_plugin::plugin_startup() { + my.reset(new chain_api_plugin_impl(app().get_plugin().chain())); auto ro_api = app().get_plugin().get_read_only_api(); auto rw_api = app().get_plugin().get_read_write_api(); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index e1da4000988..24330173656 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -67,6 +67,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { } if (options.at("resync-blockchain").as()) { ilog("Resync requested: wiping blocks"); + app().get_plugin().wipe_database(); fc::remove_all(my->block_log_file); } @@ -84,6 +85,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) { void chain_plugin::plugin_startup() { auto genesis_loader = [this] { + if (my->genesis_file.empty()) + return eos::chain::genesis_state_type(); return fc::json::from_file(my->genesis_file).as(); }; auto& db = app().get_plugin().db(); @@ -96,6 +99,8 @@ void chain_plugin::plugin_startup() { ilog("starting chain in read/write mode"); my->chain->add_checkpoints(my->loaded_checkpoints); } + + ilog("Blockchain started; head block is #${num}", ("num", my->chain->head_block_num())); } void chain_plugin::plugin_shutdown() { diff --git a/programs/eosd/main.cpp b/programs/eosd/main.cpp index 2f5aeb36199..6f404c5d233 100644 --- a/programs/eosd/main.cpp +++ b/programs/eosd/main.cpp @@ -19,7 +19,7 @@ int main(int argc, char** argv) app().register_plugin(); app().register_plugin(); - if(!app().initialize(argc, argv)) + if(!app().initialize(argc, argv)) return -1; app().startup();