Struct ipfs_sqlite_block_store::BlockStore[][src]

pub struct BlockStore<S> { /* fields omitted */ }

Implementations

impl<S> BlockStore<S> where
    S: StoreParams,
    Ipld: References<S::Codecs>, 
[src]

pub fn open_path(db_path: DbPath, config: Config) -> Result<Self>[src]

pub fn memory(config: Config) -> Result<Self>[src]

Create an in memory block store with the given config

pub fn open(path: impl AsRef<Path>, config: Config) -> Result<Self>[src]

Create a persistent block store with the given config

pub fn open_test(path: impl AsRef<Path>, config: Config) -> Result<Self>[src]

Open the file at the given path for testing.

This will create a writeable in-memory database that is initialized with the content of the file at the given path.

pub fn flush(&self) -> Result<()>[src]

pub fn integrity_check(&self) -> Result<()>[src]

pub fn transaction(&mut self) -> Result<Transaction<'_, S>>[src]

pub fn temp_pin(&self) -> TempPin[src]

Get a temporary alias for safely adding blocks to the store

pub fn alias(
    &mut self,
    name: impl AsRef<[u8]>,
    link: Option<&Cid>
) -> Result<()>
[src]

Add a permanent named alias/pin for a root

pub fn resolve(&mut self, name: impl AsRef<[u8]>) -> Result<Option<Cid>>[src]

Resolves an alias to a cid.

pub fn extend_temp_pin(
    &mut self,
    pin: &TempPin,
    links: impl IntoIterator<Item = Cid>
) -> Result<()>
[src]

pub fn reverse_alias(&mut self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>[src]

Returns the aliases referencing a block.

pub fn has_cid(&mut self, cid: &Cid) -> Result<bool>[src]

Checks if the store knows about the cid. Note that this does not necessarily mean that the store has the data for the cid.

pub fn has_block(&mut self, cid: &Cid) -> Result<bool>[src]

Checks if the store has the data for a cid

pub fn get_store_stats(&mut self) -> Result<StoreStats>[src]

Get the stats for the store.

The stats are kept up to date, so this is fast.

pub fn get_known_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>[src]

Get all cids that the store knows about

pub fn get_block_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>[src]

Get all cids for which the store has blocks

pub fn get_descendants<C: FromIterator<Cid>>(&mut self, cid: &Cid) -> Result<C>[src]

Get descendants of a cid

pub fn get_missing_blocks<C: FromIterator<Cid>>(
    &mut self,
    cid: &Cid
) -> Result<C>
[src]

Given a root of a dag, gives all cids which we do not have data for.

pub fn aliases<C: FromIterator<(Vec<u8>, Cid)>>(&mut self) -> Result<C>[src]

list all aliases

pub fn put_blocks(
    &mut self,
    blocks: impl IntoIterator<Item = Block<S>>,
    pin: Option<&TempPin>
) -> Result<()>
[src]

Add a number of blocks to the store

  • blocks the blocks to add.
  • alias an optional temporary alias. This can be used to incrementally add blocks without having to worry about them being garbage collected before they can be pinned with a permanent alias.

pub fn put_block(
    &mut self,
    block: &Block<S>,
    pin: Option<&TempPin>
) -> Result<()>
[src]

Add a single block

this is just a convenience method that calls put_blocks internally.

  • cid the cid This should be a hash of the data, with some format specifier.
  • data a blob
  • links links extracted from the data
  • alias an optional temporary alias

pub fn get_block(&mut self, cid: &Cid) -> Result<Option<Vec<u8>>>[src]

Get data for a block

Will return None if we don’t have the data

pub fn vacuum(&mut self) -> Result<()>[src]

pub fn gc(&mut self) -> Result<()>[src]

do a full garbage collection

for a large block store, this can take several seconds to minutes. If that is not acceptable, consider using incremental gc.

pub fn incremental_gc(
    &mut self,
    min_blocks: usize,
    max_duration: Duration
) -> Result<bool>
[src]

Perform an incremental garbage collection.

Will collect unpinned blocks until either the size targets are met again, or at minimum min_blocks blocks are collected. Then it will continue connecting blocks until max_duration is elapsed.

Note that this might significantly exceed max_duration for various reasons. Also note that when doing incremental gc, the actual blocks are not yet deleted. So a call to this method should usually be followed by a call to incremental_delete_orphaned.

  • min_blocks the minium number of blocks to collect in any case
  • max_duration the maximum duration that should be spent on gc

Returns true if either size targets are met or there are no unpinned blocks left.

pub fn incremental_delete_orphaned(
    &mut self,
    min_blocks: usize,
    max_duration: Duration
) -> Result<bool>
[src]

Incrementally delete orphaned blocks

Orphaned blocks are blocks for which we have deleted the metadata in incremental_gc.

Will delete orphaned blocks until either all orphaned blocks are deleted, or at minimum min_blocks blocks are deleted. Then it will continue deleting blocks until max_duration is elapsed.

Note that this might significantly exceed max_duration for various reasons.

  • min_blocks the minium number of blocks to delete in any case
  • max_duration the maximum duration that should be spent on gc

Returns true if all orphaned blocks are deleted

Auto Trait Implementations

impl<S> !RefUnwindSafe for BlockStore<S>

impl<S> Send for BlockStore<S> where
    S: Send

impl<S> !Sync for BlockStore<S>

impl<S> Unpin for BlockStore<S> where
    S: Unpin

impl<S> !UnwindSafe for BlockStore<S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> References<RawCodec> for T

pub fn references<R, E>(
    _c: RawCodec,
    _r: &mut R,
    _set: &mut E
) -> Result<(), Error> where
    E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
    R: Read

Scrape the references from an impl Read. Read more

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.