Skip to main content

IpfsBlockProvider

Trait IpfsBlockProvider 

Source
pub trait IpfsBlockProvider: Send + Sync {
    // Required methods
    fn have(&self, multihash: &Multihash<32>) -> bool;
    fn get(&self, multihash: &Multihash<32>) -> Option<Vec<u8>>;
    fn changes(&self) -> Pin<Box<dyn Stream<Item = Change> + Send>>;
}
Expand description

Provides blocks to be served over IPFS. Requires Send and Sync so we can write Arc<dyn BlockProvider> instead of Arc<dyn BlockProvider + Send + Sync>.

Required Methods§

Source

fn have(&self, multihash: &Multihash<32>) -> bool

Returns true if we have the block with the given hash.

Source

fn get(&self, multihash: &Multihash<32>) -> Option<Vec<u8>>

Returns the block with the given hash if possible, otherwise returns None.

Source

fn changes(&self) -> Pin<Box<dyn Stream<Item = Change> + Send>>

Returns a stream of changes to the available blocks. All blocks which are available at the point of calling will be reported as additions. Note that the stream may not be perfectly synchronised with have/get.

Implementors§

Source§

impl<B, C> BlockProvider for IndexedTransactions<B, C>
where B: Block, C: BlockchainEvents<B> + BlockBackend<B> + Send + Sync + 'static,