From 07757c1a09a6df8d5d9c65617cf43becc1d6b0d8 Mon Sep 17 00:00:00 2001 From: thaipandada Date: Fri, 13 Mar 2020 23:04:56 +0800 Subject: [PATCH] adjust the version and http call for create_snapshot --- CMakeLists.txt | 2 +- Docker/README.md | 4 +- README.md | 4 +- README_CN.md | 4 +- .../producer_api_plugin.cpp | 4 +- .../eosio/producer_plugin/producer_plugin.hpp | 11 +++- plugins/producer_plugin/producer_plugin.cpp | 55 +++++++++---------- 7 files changed, 43 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f92cce262d6..55259210105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 3) set(VERSION_MINOR 0) -set(VERSION_PATCH 5) +set(VERSION_PATCH 6) if(VERSION_SUFFIX) set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}") diff --git a/Docker/README.md b/Docker/README.md index 2f23146cb33..a193fc44a19 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,10 +20,10 @@ cd bos/Docker docker build . -t boscore/bos -s BOS ``` -The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v3.0.5 tag, you could do the following: +The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v3.0.6 tag, you could do the following: ```bash -docker build -t boscore/bos:v3.0.5 --build-arg branch=v3.0.5 . +docker build -t boscore/bos:v3.0.6 --build-arg branch=v3.0.6 . ``` diff --git a/README.md b/README.md index c8f6380148b..c576a181fa0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# BOSCore - Using technology to create a trusted business ecosystem +# BOSCore - Blockchain financial center building a trusted business ecosystem. -## BOSCore Version: v3.0.5 +## BOSCore Version: v3.0.6 ### Basic EOSIO Version: v1.6.6 (support REX, part 2.0.x) # Background diff --git a/README_CN.md b/README_CN.md index ce47f8b538d..6dcb8c63cfb 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,6 +1,6 @@ -# BOSCore - 用技术打造可信商业生态 +# BOSCore - 区块链自由港,构建可信商业生态。 -## BOSCore Version: v3.0.5 +## BOSCore Version: v3.0.6 ### Basic EOSIO Version: v1.6.6 (support REX, part 2.0.x) # 背景 diff --git a/plugins/producer_api_plugin/producer_api_plugin.cpp b/plugins/producer_api_plugin/producer_api_plugin.cpp index d640a6f218d..99c9c59adeb 100644 --- a/plugins/producer_api_plugin/producer_api_plugin.cpp +++ b/plugins/producer_api_plugin/producer_api_plugin.cpp @@ -89,9 +89,7 @@ void producer_api_plugin::plugin_startup() { CALL(producer, producer, get_integrity_hash, INVOKE_R_V(producer, get_integrity_hash), 201), CALL(producer, producer, create_snapshot, - INVOKE_R_V(producer, create_snapshot), 201), - CALL(producer, producer, create_acts_snapshot, - INVOKE_R_V(producer, create_acts_snapshot), 201), + INVOKE_R_R(producer, create_snapshot, producer_plugin::export_snapshot_type), 201) }); } diff --git a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp index f20d15d4fa9..0208ba9f83d 100644 --- a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp +++ b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp @@ -27,6 +27,11 @@ class producer_plugin : public appbase::plugin { fc::optional subjective_cpu_leeway_us; fc::optional incoming_defer_ratio; }; + + enum export_snapshot_type { + snapshot = 0, // snapshot for data to use for restoring a node + acts_snapshot = 1 // snapshot for all accounts with system token balance + }; struct whitelist_blacklist { fc::optional< flat_set > actor_whitelist; @@ -80,12 +85,13 @@ class producer_plugin : public appbase::plugin { void set_whitelist_blacklist(const whitelist_blacklist& params); integrity_hash_information get_integrity_hash() const; - snapshot_information create_snapshot() const; - snapshot_information create_acts_snapshot() const; + snapshot_information create_snapshot(export_snapshot_type type) const; signal confirmed_block; private: std::shared_ptr my; + snapshot_information create_blocks_snapshot(chain::controller& chain) const; + snapshot_information create_acts_snapshot(chain::controller& chain) const; }; } //eosio @@ -95,4 +101,5 @@ FC_REFLECT(eosio::producer_plugin::greylist_params, (accounts)); FC_REFLECT(eosio::producer_plugin::whitelist_blacklist, (actor_whitelist)(actor_blacklist)(contract_whitelist)(contract_blacklist)(action_blacklist)(key_blacklist) ) FC_REFLECT(eosio::producer_plugin::integrity_hash_information, (head_block_id)(integrity_hash)) FC_REFLECT(eosio::producer_plugin::snapshot_information, (head_block_id)(snapshot_name)) +FC_REFLECT_ENUM( eosio::producer_plugin::export_snapshot_type, (snapshot)(acts_snapshot) ) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 227215a7d5d..288837205be 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -955,20 +955,7 @@ producer_plugin::integrity_hash_information producer_plugin::get_integrity_hash( return {chain.head_block_id(), chain.calculate_integrity_hash()}; } -producer_plugin::snapshot_information producer_plugin::create_snapshot() const { - chain::controller& chain = my->chain_plug->chain(); - - auto reschedule = fc::make_scoped_exit([this](){ - my->schedule_production_loop(); - }); - - if (chain.pending_block_state()) { - // abort the pending block - chain.abort_block(); - } else { - reschedule.cancel(); - } - +producer_plugin::snapshot_information producer_plugin::create_blocks_snapshot(chain::controller& chain) const { auto head_id = chain.head_block_id(); std::string snapshot_path = (my->_snapshots_dir / fc::format_string("snapshot-${id}.bin", fc::mutable_variant_object()("id", head_id))).generic_string(); @@ -986,21 +973,7 @@ producer_plugin::snapshot_information producer_plugin::create_snapshot() const { return {head_id, snapshot_path}; } -producer_plugin::snapshot_information producer_plugin::create_acts_snapshot() const { - - chain::controller& chain = my->chain_plug->chain(); - - auto reschedule = fc::make_scoped_exit([this](){ - my->schedule_production_loop(); - }); - - if (chain.pending_block_state()) { - // abort the pending block - chain.abort_block(); - } else { - reschedule.cancel(); - } - +producer_plugin::snapshot_information producer_plugin::create_acts_snapshot(chain::controller& chain) const { auto head_id = chain.head_block_id(); std::string acts_snapshot_path = (my->_snapshots_dir / fc::format_string("acts-snapshot-${id}.txt", fc::mutable_variant_object()("id", head_id))).generic_string(); @@ -1027,6 +1000,30 @@ producer_plugin::snapshot_information producer_plugin::create_acts_snapshot() co return {head_id, acts_snapshot_path}; } +producer_plugin::snapshot_information producer_plugin::create_snapshot(export_snapshot_type type) const { + chain::controller& chain = my->chain_plug->chain(); + + auto reschedule = fc::make_scoped_exit([this](){ + my->schedule_production_loop(); + }); + + if (chain.pending_block_state()) { + // abort the pending block + chain.abort_block(); + } else { + reschedule.cancel(); + } + switch (type) { + case export_snapshot_type::snapshot: + return this->create_blocks_snapshot(chain); + case export_snapshot_type::acts_snapshot: + return this->create_acts_snapshot(chain); + default: + elog("Not support export_snapshot_type"); + } + return {}; +} + optional producer_plugin_impl::calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const { chain::controller& chain = chain_plug->chain(); const auto& hbs = chain.head_block_state();