mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Send only first block candidate optimistically (#1260)
* Broadcast only the first block candidate * Fix sending block broadcast --------- Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
8364a2425f
commit
1da94e62ad
22 changed files with 164 additions and 82 deletions
|
@ -553,7 +553,9 @@ void ValidatorSessionImpl::check_generate_slot() {
|
|||
LOG(WARNING) << print_id << ": failed to generate block candidate: " << R.move_as_error();
|
||||
}
|
||||
});
|
||||
callback_->on_generate_slot(cur_round_, std::move(P));
|
||||
callback_->on_generate_slot(
|
||||
BlockSourceInfo{cur_round_, first_block_round_, description().get_source_public_key(local_idx()), priority},
|
||||
std::move(P));
|
||||
} else {
|
||||
alarm_timestamp().relax(t);
|
||||
}
|
||||
|
@ -631,8 +633,10 @@ void ValidatorSessionImpl::try_approve_block(const SentBlock *block) {
|
|||
});
|
||||
pending_approve_.insert(block_id);
|
||||
|
||||
callback_->on_candidate(cur_round_, description().get_source_public_key(block->get_src_idx()), B->root_hash_,
|
||||
B->data_.clone(), B->collated_data_.clone(), std::move(P));
|
||||
callback_->on_candidate(
|
||||
BlockSourceInfo{cur_round_, first_block_round_, description().get_source_public_key(block->get_src_idx()),
|
||||
description().get_node_priority(block->get_src_idx(), cur_round_)},
|
||||
B->root_hash_, B->data_.clone(), B->collated_data_.clone(), std::move(P));
|
||||
} else if (T.is_in_past()) {
|
||||
if (!active_requests_.count(block_id)) {
|
||||
auto v = virtual_state_->get_block_approvers(description(), block_id);
|
||||
|
@ -905,15 +909,19 @@ void ValidatorSessionImpl::on_new_round(td::uint32 round) {
|
|||
stats.rounds.pop_back();
|
||||
}
|
||||
|
||||
BlockSourceInfo source_info{cur_round_, first_block_round_,
|
||||
description().get_source_public_key(block->get_src_idx()),
|
||||
description().get_node_priority(block->get_src_idx(), cur_round_)};
|
||||
if (it == blocks_.end()) {
|
||||
callback_->on_block_committed(cur_round_, description().get_source_public_key(block->get_src_idx()),
|
||||
block->get_root_hash(), block->get_file_hash(), td::BufferSlice(),
|
||||
std::move(export_sigs), std::move(export_approve_sigs), std::move(stats));
|
||||
callback_->on_block_committed(std::move(source_info), block->get_root_hash(), block->get_file_hash(),
|
||||
td::BufferSlice(), std::move(export_sigs), std::move(export_approve_sigs),
|
||||
std::move(stats));
|
||||
} else {
|
||||
callback_->on_block_committed(cur_round_, description().get_source_public_key(block->get_src_idx()),
|
||||
block->get_root_hash(), block->get_file_hash(), it->second->data_.clone(),
|
||||
std::move(export_sigs), std::move(export_approve_sigs), std::move(stats));
|
||||
callback_->on_block_committed(std::move(source_info), block->get_root_hash(), block->get_file_hash(),
|
||||
it->second->data_.clone(), std::move(export_sigs), std::move(export_approve_sigs),
|
||||
std::move(stats));
|
||||
}
|
||||
first_block_round_ = cur_round_ + 1;
|
||||
}
|
||||
cur_round_++;
|
||||
if (have_block) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue