Skip to content

Commit 1a59bf5

Browse files
committed
Inline submit_proposal_block function in Tendermint
It is hard to know whether submit_proposal_block changes step or not. Since submit_proposal_block has only two lines of code, it doesn't remove code duplication. To clarify step transition, inline the submit_proposal_block function.
1 parent f62e91d commit 1a59bf5

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

core/src/consensus/tendermint/worker.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,9 @@ impl Worker {
949949
block,
950950
} => {
951951
if !block.transactions().is_empty() {
952-
self.submit_proposal_block(&block);
952+
cinfo!(ENGINE, "Submitting proposal block {}", block.header().hash());
953+
self.move_to_step(TendermintState::Prevote, false);
954+
self.broadcast_proposal_block(self.view, encoded::Block::new(block.rlp_bytes()));
953955
} else {
954956
ctrace!(ENGINE, "Empty proposal is generated, set timer");
955957
self.step = TendermintState::ProposeWaitEmptyBlockTimer {
@@ -986,12 +988,6 @@ impl Worker {
986988
}
987989
}
988990

989-
fn submit_proposal_block(&mut self, sealed_block: &SealedBlock) {
990-
cinfo!(ENGINE, "Submitting proposal block {}", sealed_block.header().hash());
991-
self.move_to_step(TendermintState::Prevote, false);
992-
self.broadcast_proposal_block(self.view, encoded::Block::new(sealed_block.rlp_bytes()));
993-
}
994-
995991
fn backup(&self) {
996992
backup(self.client().get_kvdb().as_ref(), BackupView {
997993
height: &self.height,
@@ -1221,11 +1217,14 @@ impl Worker {
12211217
return
12221218
};
12231219

1220+
// When self.height != block.header().number() && "propose timeout" is already called,
1221+
// the state is stuck and can't move to Prevote. We should change the step to Prevote.
1222+
self.move_to_step(TendermintState::Prevote, false);
12241223
if self.height == block.header().number() {
12251224
cdebug!(ENGINE, "Empty proposal timer is finished, go to the prevote step and broadcast the block");
1226-
self.submit_proposal_block(block.as_ref());
1225+
cinfo!(ENGINE, "Submitting proposal block {}", block.header().hash());
1226+
self.broadcast_proposal_block(self.view, encoded::Block::new(block.rlp_bytes()));
12271227
} else {
1228-
self.move_to_step(TendermintState::Prevote, false);
12291228
cwarn!(ENGINE, "Empty proposal timer was for previous height.");
12301229
}
12311230

0 commit comments

Comments
 (0)