mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Improve block broadcasts processing; add special overlay for blocks for validators (#885)
* Improve block broadcast processing
* ValidatorManagerImpl::written_handle
* Retry sending broadcasts in ValidatorGroup
* Fix setting channel_ready in AdnlPeerPair
* Add special overlay for validators for block broadcasting (#842)
* Private overlay for broadcasting blocks
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
(cherry picked from commit a52045bd91
)
---------
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
a11ffb1637
commit
59927ba534
16 changed files with 410 additions and 30 deletions
|
@ -109,12 +109,14 @@ void WaitBlockState::start() {
|
|||
} else if (!handle_->inited_prev() || (!handle_->inited_proof() && !handle_->inited_proof_link())) {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), handle = handle_](td::Result<td::BufferSlice> R) {
|
||||
if (R.is_error()) {
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &WaitBlockState::start); }, td::Timestamp::in(0.1));
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof_link); },
|
||||
td::Timestamp::in(0.1));
|
||||
} else {
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::got_proof_link, R.move_as_ok());
|
||||
}
|
||||
});
|
||||
|
||||
waiting_proof_link_ = true;
|
||||
td::actor::send_closure(manager_, &ValidatorManager::send_get_block_proof_link_request, handle_->id(), priority_,
|
||||
std::move(P));
|
||||
} else if (prev_state_.is_null()) {
|
||||
|
@ -133,12 +135,14 @@ void WaitBlockState::start() {
|
|||
} else if (handle_->id().is_masterchain() && !handle_->inited_proof()) {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), handle = handle_](td::Result<td::BufferSlice> R) {
|
||||
if (R.is_error()) {
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &WaitBlockState::start); }, td::Timestamp::in(0.1));
|
||||
delay_action([SelfId]() { td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof); },
|
||||
td::Timestamp::in(0.1));
|
||||
} else {
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::got_proof, R.move_as_ok());
|
||||
}
|
||||
});
|
||||
|
||||
waiting_proof_ = true;
|
||||
td::actor::send_closure(manager_, &ValidatorManager::send_get_block_proof_request, handle_->id(), priority_,
|
||||
std::move(P));
|
||||
} else if (block_.is_null()) {
|
||||
|
@ -172,6 +176,9 @@ void WaitBlockState::got_prev_state(td::Ref<ShardState> state) {
|
|||
}
|
||||
|
||||
void WaitBlockState::got_proof_link(td::BufferSlice data) {
|
||||
if (!waiting_proof_link_) {
|
||||
return;
|
||||
}
|
||||
auto R = create_proof_link(handle_->id(), std::move(data));
|
||||
if (R.is_error()) {
|
||||
LOG(INFO) << "received bad proof link: " << R.move_as_error();
|
||||
|
@ -182,22 +189,25 @@ void WaitBlockState::got_proof_link(td::BufferSlice data) {
|
|||
if (R.is_ok()) {
|
||||
auto h = R.move_as_ok();
|
||||
CHECK(h->inited_prev());
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::start);
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof_link);
|
||||
} else {
|
||||
LOG(INFO) << "received bad proof link: " << R.move_as_error();
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::start);
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof_link);
|
||||
}
|
||||
});
|
||||
run_check_proof_link_query(handle_->id(), R.move_as_ok(), manager_, timeout_, std::move(P));
|
||||
}
|
||||
|
||||
void WaitBlockState::got_proof(td::BufferSlice data) {
|
||||
if (!waiting_proof_) {
|
||||
return;
|
||||
}
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Unit> R) {
|
||||
if (R.is_ok()) {
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::start);
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof);
|
||||
} else {
|
||||
LOG(INFO) << "received bad proof link: " << R.move_as_error();
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::start);
|
||||
td::actor::send_closure(SelfId, &WaitBlockState::after_get_proof);
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(manager_, &ValidatorManager::validate_block_proof, handle_->id(), std::move(data),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue