use {solana_clock::Slot, solana_hash::HASH_BYTES};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SlotStatusKind {
FirstShredReceived,
Completed,
CreatedBank,
Dead,
Processed,
Confirmed,
Finalized,
Other,
}
#[derive(Debug, Clone, Copy)]
pub struct SlotUpdateEvInfo {
pub slot: Slot,
pub parent: Option<Slot>,
pub status: SlotStatusKind,
pub dead_error: bool,
}
#[derive(Debug, Clone, Copy)]
pub struct BlockMetaEvInfo {
pub slot: Slot,
pub parent_slot: Slot,
pub entries_count: u64,
pub executed_transaction_count: u64,
pub blockhash: [u8; HASH_BYTES],
}
#[derive(Debug, Clone, Copy)]
pub struct EntryEvInfo {
pub slot: Slot,
pub index: u64,
pub starting_transaction_index: u64,
pub executed_transaction_count: u64,
pub hash: [u8; HASH_BYTES],
}
#[derive(Debug, Clone)]
pub enum GeyserEventInfo {
Slot(SlotUpdateEvInfo),
BlockMeta(BlockMetaEvInfo),
Entry(EntryEvInfo),
Transaction {
slot: Slot,
},
Account {
slot: Slot,
},
Other {
slot: Slot,
},
}
impl GeyserEventInfo {
pub fn slot(&self) -> Slot {
match self {
GeyserEventInfo::Slot(ev) => ev.slot,
GeyserEventInfo::BlockMeta(ev) => ev.slot,
GeyserEventInfo::Entry(ev) => ev.slot,
GeyserEventInfo::Transaction { slot } => *slot,
GeyserEventInfo::Account { slot } => *slot,
GeyserEventInfo::Other { slot } => *slot,
}
}
}
pub trait GeyserEventAdapter {
type EventT;
fn extract_geyser_ev_info(event: &Self::EventT) -> Option<GeyserEventInfo>;
}