Skip to content

Commit f3b58b4

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 53f5521 commit f3b58b4

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,
@@ -1227,11 +1223,14 @@ impl Worker {
12271223
return
12281224
};
12291225

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

0 commit comments

Comments
 (0)