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