stratus/eth/primitives/
pending_block.rs1use display_json::DebugAsJson;
2use indexmap::IndexMap;
3
4use crate::eth::primitives::BlockNumber;
5use crate::eth::primitives::ExternalBlock;
6use crate::eth::primitives::Hash;
7use crate::eth::primitives::PendingBlockHeader;
8use crate::eth::primitives::TransactionExecution;
9
10#[derive(DebugAsJson, Clone, Default, serde::Serialize)]
12pub struct PendingBlock {
13 pub header: PendingBlockHeader,
14 pub transactions: IndexMap<Hash, TransactionExecution>,
16 pub external_block: Option<ExternalBlock>,
17}
18
19impl PendingBlock {
20 pub fn new_at_now(number: BlockNumber) -> Self {
22 Self {
23 header: PendingBlockHeader::new_at_now(number),
24 transactions: IndexMap::new(),
25 external_block: None,
26 }
27 }
28
29 pub fn push_transaction(&mut self, tx: TransactionExecution) {
31 self.transactions.insert(tx.input.hash, tx);
32 }
33}