[−][src]Struct ipfs_sqlite_block_store::BlockStore
Implementations
impl BlockStore
[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 integrity_check(&self) -> Result<()>
[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]
&mut self,
name: impl AsRef<[u8]>,
link: Option<&Cid>
) -> Result<()>
Add a permanent named alias/pin for a root
pub fn alias_many(
&mut self,
aliases: impl IntoIterator<Item = (impl AsRef<[u8]>, Option<Cid>)>
) -> Result<()>
[src]
&mut self,
aliases: impl IntoIterator<Item = (impl AsRef<[u8]>, Option<Cid>)>
) -> Result<()>
Add multiple permanent named aliases
pub fn reverse_alias(&mut self, cid: &Cid) -> Result<Vec<Vec<u8>>>
[src]
Returns the aliases referencing a block.
pub fn has_cid(&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 has_blocks<I, O>(&self, cids: I) -> Result<O> where
I: IntoIterator<Item = Cid>,
O: FromIterator<(Cid, bool)>,
[src]
I: IntoIterator<Item = Cid>,
O: FromIterator<(Cid, bool)>,
Look up multiple blocks in one read transaction
pub fn get_store_stats(&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]
&mut self,
cid: &Cid
) -> Result<C>
Given a root of a dag, gives all cids which we do not have data for.
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]
&mut self,
min_blocks: usize,
max_duration: Duration
) -> Result<bool>
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]
&mut self,
min_blocks: usize,
max_duration: Duration
) -> Result<bool>
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
pub fn put_blocks<B: Block>(
&mut self,
blocks: impl IntoIterator<Item = B>,
alias: Option<&TempPin>
) -> Result<()>
[src]
&mut self,
blocks: impl IntoIterator<Item = B>,
alias: Option<&TempPin>
) -> Result<()>
Add a number of blocks to the store
It is up to the caller to extract links from blocks. Also, the store does not know anything about content-addressing and will not validate that the cid of a block is the actual hash of the content.
blocks
the blocks to add. Even we already have these blocks, the alias will be set. However, it will not be checked that the links or data are the same as last time the block was added. That is responsibility of the caller.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<I>(
&mut self,
cid: &Cid,
data: &[u8],
links: I,
alias: Option<&TempPin>
) -> Result<()> where
I: IntoIterator<Item = Cid> + Clone,
[src]
&mut self,
cid: &Cid,
data: &[u8],
links: I,
alias: Option<&TempPin>
) -> Result<()> where
I: IntoIterator<Item = Cid> + Clone,
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_blocks<I>(
&mut self,
cids: I
) -> Result<impl Iterator<Item = (Cid, Option<Vec<u8>>)>> where
I: IntoIterator<Item = Cid>,
[src]
&mut self,
cids: I
) -> Result<impl Iterator<Item = (Cid, Option<Vec<u8>>)>> where
I: IntoIterator<Item = Cid>,
Get multiple blocks in a single read transaction
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
Auto Trait Implementations
impl !RefUnwindSafe for BlockStore
[src]
impl Send for BlockStore
[src]
impl !Sync for BlockStore
[src]
impl Unpin for BlockStore
[src]
impl !UnwindSafe for BlockStore
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> References<RawCodec> for T
pub fn references<R, E>(
_c: RawCodec,
_r: &mut R,
_set: &mut E
) -> Result<(), Error> where
R: Read,
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
_c: RawCodec,
_r: &mut R,
_set: &mut E
) -> Result<(), Error> where
R: Read,
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
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]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,