Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from eosnetworkfoundation/snapshot-info
Browse files Browse the repository at this point in the history
Backport 2.1 enhanced snapshot reporting
  • Loading branch information
tbfleming authored Jan 21, 2022
2 parents b5b2cea + 83e2eb1 commit 979a449
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class producer_plugin : public appbase::plugin<producer_plugin> {

struct snapshot_information {
chain::block_id_type head_block_id;
uint32_t head_block_num;
fc::time_point head_block_time;
uint32_t version;
std::string snapshot_name;
};

Expand Down Expand Up @@ -123,7 +126,7 @@ FC_REFLECT(eosio::producer_plugin::runtime_options, (max_transaction_time)(max_i
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(eosio::producer_plugin::snapshot_information, (head_block_id)(head_block_num)(head_block_time)(version)(snapshot_name))
FC_REFLECT(eosio::producer_plugin::scheduled_protocol_feature_activations, (protocol_features_to_activate))
FC_REFLECT(eosio::producer_plugin::get_supported_protocol_features_params, (exclude_disabled)(exclude_unactivatable))
FC_REFLECT(eosio::producer_plugin::get_account_ram_corrections_params, (lower_bound)(upper_bound)(limit)(reverse))
Expand Down
13 changes: 8 additions & 5 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ class pending_snapshot {
}

producer_plugin::snapshot_information finalize( const chain::controller& chain ) const {
auto in_chain = (bool)chain.fetch_block_by_id( block_id );
auto block_ptr = chain.fetch_block_by_id( block_id );
auto in_chain = (bool)block_ptr;
boost::system::error_code ec;

if (!in_chain) {
Expand All @@ -152,7 +153,7 @@ class pending_snapshot {
("ec", ec.value())
("message", ec.message()));

return {block_id, final_path};
return {block_id, block_ptr->block_num(), block_ptr->timestamp, chain_snapshot_header::current_version, final_path};
}

block_id_type block_id;
Expand Down Expand Up @@ -1226,6 +1227,8 @@ void producer_plugin::create_snapshot(producer_plugin::next_function<producer_pl
chain::controller& chain = my->chain_plug->chain();

auto head_id = chain.head_block_id();
const auto head_block_num = chain.head_block_num();
const auto head_block_time = chain.head_block_time();
const auto& snapshot_path = pending_snapshot::get_final_path(head_id, my->_snapshots_dir);
const auto& temp_path = pending_snapshot::get_temp_path(head_id, my->_snapshots_dir);

Expand Down Expand Up @@ -1268,11 +1271,11 @@ void producer_plugin::create_snapshot(producer_plugin::next_function<producer_pl
bfs::rename(temp_path, snapshot_path, ec);
EOS_ASSERT(!ec, snapshot_finalization_exception,
"Unable to finalize valid snapshot of block number ${bn}: [code: ${ec}] ${message}",
("bn", chain.head_block_num())
("bn", head_block_num)
("ec", ec.value())
("message", ec.message()));

next( producer_plugin::snapshot_information{head_id, snapshot_path.generic_string()} );
next( producer_plugin::snapshot_information{head_id, head_block_num, head_block_time, chain_snapshot_header::current_version, snapshot_path.generic_string()} );
} CATCH_AND_CALL (next);
return;
}
Expand Down Expand Up @@ -1300,7 +1303,7 @@ void producer_plugin::create_snapshot(producer_plugin::next_function<producer_pl
bfs::rename(temp_path, pending_path, ec);
EOS_ASSERT(!ec, snapshot_finalization_exception,
"Unable to promote temp snapshot to pending for block number ${bn}: [code: ${ec}] ${message}",
("bn", chain.head_block_num())
("bn", head_block_num)
("ec", ec.value())
("message", ec.message()));

Expand Down

0 comments on commit 979a449

Please sign in to comment.