Skip to content

Commit

Permalink
adjust the version and http call for create_snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaipanda committed Mar 13, 2020
1 parent c7d9e4b commit 07757c1
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

```

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -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)

# 背景
Expand Down
4 changes: 1 addition & 3 deletions plugins/producer_api_plugin/producer_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class producer_plugin : public appbase::plugin<producer_plugin> {
fc::optional<int32_t> subjective_cpu_leeway_us;
fc::optional<double> 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<account_name> > actor_whitelist;
Expand Down Expand Up @@ -80,12 +85,13 @@ class producer_plugin : public appbase::plugin<producer_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<void(const chain::producer_confirmation&)> confirmed_block;
private:
std::shared_ptr<class producer_plugin_impl> my;
snapshot_information create_blocks_snapshot(chain::controller& chain) const;
snapshot_information create_acts_snapshot(chain::controller& chain) const;
};

} //eosio
Expand All @@ -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) )

55 changes: 26 additions & 29 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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<fc::time_point> 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();
Expand Down

0 comments on commit 07757c1

Please sign in to comment.