mithril_common::cardano_block_scanner

Trait BlockScanner

source
pub trait BlockScanner: Sync + Send {
    // Required method
    fn scan<'life0, 'async_trait>(
        &'life0 self,
        from: Option<RawCardanoPoint>,
        until: BlockNumber,
    ) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn BlockStreamer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A scanner that can read cardano transactions in a cardano database

If you want to mock it using mockall:

mod test {
    use std::path::Path;

    use anyhow::anyhow;
    use async_trait::async_trait;
    use mockall::mock;

    use mithril_common::cardano_block_scanner::{BlockScanner, BlockStreamer, RawCardanoPoint};
    use mithril_common::entities::{BlockNumber};
    use mithril_common::StdResult;

    mock! {
        pub BlockScannerImpl { }

        #[async_trait]
        impl BlockScanner for BlockScannerImpl {
            async fn scan(
              &self,
              from: Option<RawCardanoPoint>,
              until: BlockNumber,
            ) -> StdResult<Box<dyn BlockStreamer>>;
        }
    }

    #[test]
    fn test_mock() {
        let mut mock = MockBlockScannerImpl::new();
        mock.expect_scan().return_once(|_, _| {
            Err(anyhow!("parse error"))
        });
    }
}

Required Methods§

source

fn scan<'life0, 'async_trait>( &'life0 self, from: Option<RawCardanoPoint>, until: BlockNumber, ) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn BlockStreamer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Scan the transactions

Implementors§