Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IF: Unification: Add block header extension (last part) #2097

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
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
15 changes: 12 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,18 @@ struct building_block {
const block_data_new_t& bd = std::get<block_data_new_t>(block_data.v);
const auto& fork_db = bd.fork_db; // fork_db<block_state_ptr, block_header_state_ptr>

// [greg todo] retrieve qc, and fill the following struct accurately
std::optional<qc_data_t> qc_data; // Comes from traversing branch from parent and calling
// get_best_qc() assert(qc->block_num <= num_from_id(previous));
// find most recent ancestor block that has a QC by traversing fork db
// branch from parent
std::optional<qc_data_t> qc_data;
auto branch = fork_db.fetch_branch(parent_id());
for( auto it = branch.begin(); it != branch.end(); ++it ) {
auto qc = (*it)->get_best_qc();
if( qc ) {
EOS_ASSERT( qc->block_height <= block_header::num_from_id(parent_id()), block_validate_exception, "most recent ancestor QC block number (${a}) cannot be greater than parent's block number (${p})", ("a", qc->block_height)("p", block_header::num_from_id(parent_id())) );
qc_data = qc_data_t{ *qc, qc_info_t{ qc->block_height, qc->qc.is_strong() }};
break;
}
}

building_block_input bb_input {
.parent_id = parent_id(),
Expand Down