kabu_types_events/
node.rs1use crate::Message;
2use alloy_primitives::TxHash;
3use kabu_types_blockchain::{GethStateUpdateVec, KabuHeader, MempoolTx};
4use kabu_types_blockchain::{KabuDataTypes, KabuDataTypesEthereum};
5
6#[derive(Clone, Debug)]
7pub struct NodeMempoolDataUpdate<LDT: KabuDataTypes = KabuDataTypesEthereum> {
8 pub tx_hash: TxHash,
9 pub mempool_tx: MempoolTx<LDT>,
10}
11
12#[derive(Clone, Debug)]
13pub struct BlockUpdate<LDT: KabuDataTypes = KabuDataTypesEthereum> {
14 pub block: LDT::Block,
15}
16
17#[derive(Clone, Debug)]
18pub struct BlockStateUpdate<LDT: KabuDataTypes = KabuDataTypesEthereum> {
19 pub block_header: LDT::Header,
20 pub state_update: GethStateUpdateVec,
21}
22
23#[derive(Clone, Debug)]
24pub struct BlockLogs<LDT: KabuDataTypes = KabuDataTypesEthereum> {
25 pub block_header: LDT::Header,
26 pub logs: Vec<LDT::Log>,
27}
28
29#[derive(Clone, Debug, Default)]
30pub struct BlockHeaderEventData<LDT: KabuDataTypes = KabuDataTypesEthereum> {
31 pub header: LDT::Header,
32 pub next_block_number: u64,
33 pub next_block_timestamp: u64,
34}
35
36pub type MessageMempoolDataUpdate<LDT = KabuDataTypesEthereum> = Message<NodeMempoolDataUpdate<LDT>>;
37
38pub type MessageBlockHeader<LDT = KabuDataTypesEthereum> = Message<BlockHeaderEventData<LDT>>;
39pub type MessageBlock<LDT = KabuDataTypesEthereum> = Message<BlockUpdate<LDT>>;
40pub type MessageBlockLogs<LDT = KabuDataTypesEthereum> = Message<BlockLogs<LDT>>;
41pub type MessageBlockStateUpdate<LDT = KabuDataTypesEthereum> = Message<BlockStateUpdate<LDT>>;
42
43impl<LDT: KabuDataTypes> BlockHeaderEventData<LDT> {
44 pub fn new(header: LDT::Header) -> Self {
45 let next_block_number = header.get_number() + 1;
46 let next_block_timestamp = header.get_timestamp() + 12;
47 Self { header, next_block_number, next_block_timestamp }
48 }
49}