pub trait BlockScanner: Sync + Send {
    // Required method
    fn scan<'life0, 'life1, 'async_trait>(
        &'life0 self,
        dirpath: &'life1 Path,
        from_immutable: Option<ImmutableFileNumber>,
        until_immutable: ImmutableFileNumber
    ) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn BlockStreamer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: '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, ScannedBlock};
    use mithril_common::entities::{CardanoDbBeacon, CardanoTransaction, ImmutableFileNumber};
    use mithril_common::StdResult;

    mock! {
        pub BlockScannerImpl { }

        #[async_trait]
        impl BlockScanner for BlockScannerImpl {
            async fn scan(
              &self,
              dirpath: &Path,
              from_immutable: Option<ImmutableFileNumber>,
              until_immutable: ImmutableFileNumber,
            ) -> 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, 'life1, 'async_trait>( &'life0 self, dirpath: &'life1 Path, from_immutable: Option<ImmutableFileNumber>, until_immutable: ImmutableFileNumber ) -> Pin<Box<dyn Future<Output = StdResult<Box<dyn BlockStreamer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Scan the transactions

Implementors§