Skip to content

Commit b374d7e

Browse files
committed
Introduce on_open_block
`on_open_block` is called when the block is created, before processing any transactions included in the block.
1 parent 60a235b commit b374d7e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

core/src/consensus/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ pub trait ConsensusEngine: Sync + Send {
221221
/// Stops any services that the may hold the Engine and makes it safe to drop.
222222
fn stop(&self) {}
223223

224+
/// Block transformation functions, before the transactions.
225+
fn on_open_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error> {
226+
Ok(())
227+
}
228+
224229
/// Block transformation functions, after the transactions.
225230
fn on_close_block(
226231
&self,

core/src/consensus/tendermint/engine.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ impl ConsensusEngine for Tendermint {
134134

135135
fn stop(&self) {}
136136

137+
/// Block transformation functions, before the transactions.
138+
fn on_open_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> {
139+
let metadata = block.state().metadata()?.expect("Metadata must exist");
140+
if block.header().number() == metadata.last_term_finished_block_num() + 1 {
141+
// FIXME: on_term_open
142+
}
143+
Ok(())
144+
}
145+
137146
fn on_close_block(
138147
&self,
139148
block: &mut ExecutedBlock,

0 commit comments

Comments
 (0)