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

Add log path for unsupported block log version exception #9905

Merged
merged 3 commits into from
Jan 19, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions libraries/chain/block_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace eosio { namespace chain {
uint32_t version = 0;
uint32_t first_block_num = 0;
std::variant<genesis_state, chain_id_type> chain_context;
fc::path log_path;


chain_id_type chain_id() const {
return std::visit(overloaded{[](const chain_id_type& id) { return id; },
Expand All @@ -53,8 +55,8 @@ namespace eosio { namespace chain {
EOS_ASSERT(
block_log::is_supported_version(version), block_log_unsupported_version,
"Unsupported version of block log. Block log version is ${version} while code supports version(s) "
"[${min},${max}]",
("version", version)("min", block_log::min_supported_version)("max", block_log::max_supported_version));
"[${min},${max}], log file: ${log}",
("version", version)("min", block_log::min_supported_version)("max", block_log::max_supported_version)("log", log_path));

first_block_num = 1;
if (version != initial_version) {
Expand Down Expand Up @@ -279,7 +281,10 @@ namespace eosio { namespace chain {
public:

block_log_data() = default;
block_log_data(const fc::path& path, mapmode mode = mapmode::readonly) { open(path, mode); }
block_log_data(const fc::path& path, mapmode mode = mapmode::readonly) {
preamble.log_path = path;
open(path, mode);
}

const block_log_preamble& get_preamble() const { return preamble; }

heifner marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -297,6 +302,7 @@ namespace eosio { namespace chain {
uint32_t first_block_num() const { return preamble.first_block_num; }
uint64_t first_block_position() const { return first_block_pos; }
chain_id_type chain_id() const { return preamble.chain_id(); }
fc::path log_path() const { return preamble.log_path; }
heifner marked this conversation as resolved.
Show resolved Hide resolved

std::optional<genesis_state> get_genesis_state() const {
return std::visit(overloaded{[](const chain_id_type&) { return std::optional<genesis_state>{}; },
Expand Down Expand Up @@ -398,11 +404,11 @@ namespace eosio { namespace chain {
block_log_data log_data;
block_log_index log_index;

block_log_bundle(fc::path block_dir) {
block_file_name = block_dir / "blocks.log";
block_log_bundle(fc::path block_dir)
: block_file_name (block_dir / "blocks.log")
, log_data(block_file_name)
{
index_file_name = block_dir / "blocks.index";

log_data.open(block_file_name);
log_index.open(index_file_name);

uint32_t log_num_blocks = log_data.num_blocks();
Expand Down