Struct ipfs_sqlite_block_store::BlockStore
source · [−]pub struct BlockStore<S> { /* private fields */ }
Implementations
sourceimpl<S> BlockStore<S>where
S: StoreParams,
Ipld: References<S::Codecs>,
impl<S> BlockStore<S>where
S: StoreParams,
Ipld: References<S::Codecs>,
pub fn open_path(db_path: DbPath, config: Config) -> Result<Self>
sourcepub fn additional_connection(&self) -> Result<Self>
pub fn additional_connection(&self) -> Result<Self>
Create another connection to the underlying database
This allows you to perform operations in parallel.
sourcepub fn memory(config: Config) -> Result<Self>
pub fn memory(config: Config) -> Result<Self>
Create an in memory block store with the given config
sourcepub fn open(path: impl AsRef<Path>, config: Config) -> Result<Self>
pub fn open(path: impl AsRef<Path>, config: Config) -> Result<Self>
Create a persistent block store with the given config
sourcepub fn open_test(path: impl AsRef<Path>, config: Config) -> Result<Self>
pub fn open_test(path: impl AsRef<Path>, config: Config) -> Result<Self>
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 backup(&mut self, path: PathBuf) -> Result<()>
pub fn flush(&mut self) -> Result<()>
pub fn integrity_check(&mut self) -> Result<()>
pub fn transaction(&mut self) -> Transaction<'_, S>
sourcepub fn vacuum(&mut self) -> Result<()>
pub fn vacuum(&mut self) -> Result<()>
Run a full VACUUM on the SQLITE database
This may take a while, blocking all other writes to the store.
sourcepub fn cleanup_temp_pins(&mut self) -> Result<()>
pub fn cleanup_temp_pins(&mut self) -> Result<()>
Perform maintenance on the TempPins
This is done automatically upon every (incremental) GC, so you normally don’t need to call this.
sourcepub fn gc(&mut self) -> Result<()>
pub fn gc(&mut self) -> Result<()>
Perform full GC
This is the same as running incremental GC without limits, plus a full SQLITE VACUUM.
sourcepub fn incremental_gc(
&mut self,
min_blocks: usize,
max_duration: Duration
) -> Result<bool>
pub fn incremental_gc(
&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 collecting blocks until max_duration
is elapsed.
Note that this might significantly exceed max_duration
for various reasons.
Returns true if either size targets are met or there are no unpinned blocks left.
sourceimpl<S> BlockStore<S>where
S: StoreParams,
Ipld: References<S::Codecs>,
impl<S> BlockStore<S>where
S: StoreParams,
Ipld: References<S::Codecs>,
sourcepub fn alias<'b>(
&mut self,
name: impl Into<Cow<'b, [u8]>>,
link: Option<&'b Cid>
) -> Result<()>
pub fn alias<'b>(
&mut self,
name: impl Into<Cow<'b, [u8]>>,
link: Option<&'b Cid>
) -> Result<()>
Set or delete an alias
sourcepub fn resolve<'b>(
&mut self,
name: impl Into<Cow<'b, [u8]>>
) -> Result<Option<Cid>>
pub fn resolve<'b>(
&mut self,
name: impl Into<Cow<'b, [u8]>>
) -> Result<Option<Cid>>
Resolves an alias to a cid
sourcepub fn reverse_alias(&mut self, cid: &Cid) -> Result<Option<HashSet<Vec<u8>>>>
pub fn reverse_alias(&mut self, cid: &Cid) -> Result<Option<HashSet<Vec<u8>>>>
Returns the aliases referencing a cid
sourcepub fn extend_temp_pin(&mut self, pin: &mut TempPin, link: &Cid) -> Result<()>
pub fn extend_temp_pin(&mut self, pin: &mut TempPin, link: &Cid) -> Result<()>
Extend temp pin with an additional cid
sourcepub fn has_cid(&mut self, cid: &Cid) -> Result<bool>
pub fn has_cid(&mut self, cid: &Cid) -> Result<bool>
Checks if the store knows about the cid.
Note that this does not necessarily mean that the store has the data for the cid.
sourcepub fn has_block(&mut self, cid: &Cid) -> Result<bool>
pub fn has_block(&mut self, cid: &Cid) -> Result<bool>
Checks if the store has the data for a cid
sourcepub fn get_known_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>
pub fn get_known_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>
Get all cids that the store knows about
sourcepub fn get_block_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>
pub fn get_block_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>
Get all cids for which the store has blocks
sourcepub fn get_descendants<C: FromIterator<Cid>>(&mut self, cid: &Cid) -> Result<C>
pub fn get_descendants<C: FromIterator<Cid>>(&mut self, cid: &Cid) -> Result<C>
Get descendants of a cid
sourcepub fn get_missing_blocks<C: FromIterator<Cid>>(
&mut self,
cid: &Cid
) -> Result<C>
pub fn get_missing_blocks<C: FromIterator<Cid>>(
&mut self,
cid: &Cid
) -> Result<C>
Given a root of a dag, gives all cids which we do not have data for.
sourcepub fn put_block(
&mut self,
block: Block<S>,
pin: Option<&mut TempPin>
) -> Result<()>
pub fn put_block(
&mut self,
block: Block<S>,
pin: Option<&mut TempPin>
) -> Result<()>
Put a block
This will only be completed once the transaction is successfully committed.
sourcepub fn get_store_stats(&mut self) -> Result<StoreStats>
pub fn get_store_stats(&mut self) -> Result<StoreStats>
Get the stats for the store
The stats are kept up to date, so this is fast.