Skip to content

Commit f4468b8

Browse files
committed
Send broadcasts earlier in AcceptBlock
1 parent 0326fc5 commit f4468b8

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

validator/impl/accept-block.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,17 @@ void AcceptBlockQuery::written_block_signatures() {
494494
void AcceptBlockQuery::written_block_info() {
495495
VLOG(VALIDATOR_DEBUG) << "written block info";
496496
if (data_.not_null()) {
497+
block_root_ = data_->root_cell();
498+
if (block_root_.is_null()) {
499+
fatal_error("block data does not contain a root cell");
500+
return;
501+
}
502+
// generate proof
503+
if (!create_new_proof()) {
504+
fatal_error("cannot generate proof for block "s + id_.to_str());
505+
return;
506+
}
507+
send_broadcasts();
497508
if (!apply_) {
498509
written_state({});
499510
return;
@@ -563,17 +574,6 @@ void AcceptBlockQuery::written_state(td::Ref<ShardState> upd_state) {
563574
CHECK(data_.not_null());
564575
state_ = std::move(upd_state);
565576

566-
block_root_ = data_->root_cell();
567-
if (block_root_.is_null()) {
568-
fatal_error("block data does not contain a root cell");
569-
return;
570-
}
571-
// generate proof
572-
if (!create_new_proof()) {
573-
fatal_error("cannot generate proof for block "s + id_.to_str());
574-
return;
575-
}
576-
577577
if (apply_ && state_keep_old_hash_ != state_old_hash_) {
578578
fatal_error(PSTRING() << "invalid previous state hash in newly-created proof: expected "
579579
<< state_->root_hash().to_hex() << ", found in update " << state_old_hash_.to_hex());
@@ -935,8 +935,11 @@ void AcceptBlockQuery::written_block_info_2() {
935935
}
936936

937937
void AcceptBlockQuery::applied() {
938+
finish_query();
939+
}
940+
941+
void AcceptBlockQuery::send_broadcasts() {
938942
if (send_broadcast_mode_ == 0) {
939-
finish_query();
940943
return;
941944
}
942945
BlockBroadcast b;
@@ -964,8 +967,6 @@ void AcceptBlockQuery::applied() {
964967
// td::actor::send_closure(manager_, &ValidatorManager::send_block_candidate_broadcast, id_,
965968
// validator_set_->get_catchain_seqno(), validator_set_->get_validator_set_hash(),
966969
// std::move(b.data), send_broadcast_mode_);
967-
968-
finish_query();
969970
}
970971

971972
} // namespace validator

validator/impl/accept-block.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class AcceptBlockQuery : public td::actor::Actor {
8989
void written_block_next();
9090
void written_block_info_2();
9191
void applied();
92+
void send_broadcasts();
9293

9394
private:
9495
BlockIdExt id_;

0 commit comments

Comments
 (0)