Trait subspace_farmer::farm::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 piece is potentially stored in this cache (not guaranteed to be because it might be overridden with 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, otherwise Ok(false) is returned

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§