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]
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]
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]
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]
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 alias(
&mut self,
name: impl AsRef<[u8]>,
link: Option<&Cid>
) -> Result<()>
[src]
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]
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]
&mut self,
pin: &TempPin,
links: impl IntoIterator<Item = Cid>
) -> Result<()>
pub fn reverse_alias(&mut self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>
[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]
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]
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]
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]
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]
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]
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]
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 put_blocks(
&mut self,
blocks: impl IntoIterator<Item = Block<S>>,
pin: Option<&TempPin>
) -> Result<()>
[src]
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]
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 bloblinks
links extracted from the dataalias
an optional temporary alias
pub fn get_block(&mut self, cid: &Cid) -> Result<Option<Vec<u8>>>
[src]
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]
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]
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 casemax_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]
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 casemax_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,
S: Send,
impl<S> !Sync for BlockStore<S>
impl<S> Unpin for BlockStore<S> where
S: Unpin,
S: Unpin,
impl<S> !UnwindSafe for BlockStore<S>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[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]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self