Trait PlotCache

Source
pub trait PlotCache:
    Send
    + Sync
    + Debug {
    // Required methods
    fn is_piece_maybe_stored<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 RecordKey,
    ) -> Pin<Box<dyn Future<Output = Result<MaybePieceStoredResult, FarmError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn try_store_piece<'life0, 'life1, 'async_trait>(
        &'life0 self,
        piece_index: PieceIndex,
        piece: &'life1 Piece,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FarmError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn read_piece<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 RecordKey,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Piece>, FarmError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Abstract plot cache implementation.

Plot cache is a cache that exploits space towards the end of the plot that is not yet occupied by sectors in order to increase effective caching space, which helps with plotting speed for small farmers since they don’t need to retrieve the same pieces from the network over and over again, which is slower and uses a lot of Internet bandwidth.

Required Methods§

Source

fn is_piece_maybe_stored<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 RecordKey, ) -> Pin<Box<dyn Future<Output = Result<MaybePieceStoredResult, FarmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a piece is already stored in this cache, or it can be added to this cache. The piece is not guaranteed to be stored, because it might be overwritten with a new sector any time.

Source

fn try_store_piece<'life0, 'life1, 'async_trait>( &'life0 self, piece_index: PieceIndex, piece: &'life1 Piece, ) -> Pin<Box<dyn Future<Output = Result<bool, FarmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store piece in cache if there is free space, and return Ok(true). Returns Ok(false) if there is no free space, or the farm or process is shutting down.

Source

fn read_piece<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 RecordKey, ) -> Pin<Box<dyn Future<Output = Result<Option<Piece>, FarmError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read piece from cache.

Returns None if not cached.

Implementors§