1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use fuel_core_interfaces::{
common::{
fuel_asm::Word,
fuel_tx::{
Receipt,
Transaction,
},
},
db::DatabaseTransaction,
executor::UncommittedResult,
model::{
BlockHeight,
BlockId,
FuelBlockConsensus,
},
};
pub trait BlockDb: Send + Sync {
fn block_height(&self) -> anyhow::Result<BlockHeight>;
fn seal_block(
&mut self,
block_id: BlockId,
consensus: FuelBlockConsensus,
) -> anyhow::Result<()>;
}
pub type DBTransaction<Database> = Box<dyn DatabaseTransaction<Database>>;
#[async_trait::async_trait]
pub trait BlockProducer<Database>: Send + Sync {
async fn produce_and_execute_block(
&self,
height: BlockHeight,
max_gas: Word,
) -> anyhow::Result<UncommittedResult<DBTransaction<Database>>>;
async fn dry_run(
&self,
transaction: Transaction,
height: Option<BlockHeight>,
utxo_validation: Option<bool>,
) -> anyhow::Result<Vec<Receipt>>;
}