Struct ipfs_sqlite_block_store::BlockStore[][src]

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

Implementations

Create an in memory block store with the given config

Create a persistent block store with the given config

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.

Get a temporary alias for safely adding blocks to the store

Add a permanent named alias/pin for a root

Resolves an alias to a cid.

Returns the aliases referencing a block.

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

Checks if the store has the data for a cid

Get the stats for the store.

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

Get all cids that the store knows about

Get all cids for which the store has blocks

Get descendants of a cid

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

list all aliases

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.

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

Get data for a block

Will return None if we don’t have the data

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.

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.

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

Scrape the references from an impl Read. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.