cometindex/
contextualized.rs

1use tendermint::abci::Event;
2
3#[derive(Clone, Copy, Debug)]
4pub struct ContextualizedEvent<'block> {
5    pub event: &'block Event,
6    pub block_height: u64,
7    pub tx: Option<([u8; 32], &'block [u8])>,
8    /// The rowid of the event in the local database.
9    ///
10    /// Note that this is a purely local identifier and won't be the same across
11    /// different event databases.
12    pub local_rowid: i64,
13}
14
15impl<'block> ContextualizedEvent<'block> {
16    pub fn tx_hash(&self) -> Option<[u8; 32]> {
17        self.tx.map(|x| x.0)
18    }
19
20    pub fn tx_data(&self) -> Option<&'block [u8]> {
21        self.tx.map(|x| x.1)
22    }
23}
24
25impl<'tx> AsRef<Event> for ContextualizedEvent<'tx> {
26    fn as_ref(&self) -> &Event {
27        &self.event
28    }
29}