pub struct Store<C>{ /* private fields */ }
Expand description
Persists an append-only list of changesets (C
) to a single file.
⚠ This is a development/testing database. It does not natively support backwards compatible BDK version upgrades so should not be used in production.
Implementations§
Source§impl<C> Store<C>
impl<C> Store<C>
Sourcepub fn create_new<P>(magic: &[u8], file_path: P) -> Result<Self, FileError>
pub fn create_new<P>(magic: &[u8], file_path: P) -> Result<Self, FileError>
Sourcepub fn open<P>(magic: &[u8], file_path: P) -> Result<Self, FileError>
pub fn open<P>(magic: &[u8], file_path: P) -> Result<Self, FileError>
Open an existing Store
.
Use create_new
to create a new Store
.
§Errors
If the prefixed bytes of the opened file does not match the provided magic
, the
FileError::InvalidMagicBytes
error variant will be returned.
Sourcepub fn open_or_create_new<P>(
magic: &[u8],
file_path: P,
) -> Result<Self, FileError>
pub fn open_or_create_new<P>( magic: &[u8], file_path: P, ) -> Result<Self, FileError>
Attempt to open existing Store
file; create it if the file is non-existent.
Internally, this calls either open
or create_new
.
Sourcepub fn iter_changesets(&mut self) -> EntryIter<'_, C> ⓘ
pub fn iter_changesets(&mut self) -> EntryIter<'_, C> ⓘ
Iterates over the stored changeset from first to last, changing the seek position at each iteration.
The iterator may fail to read an entry and therefore return an error. However, the first time
it returns an error will be the last. After doing so, the iterator will always yield None
.
WARNING: This method changes the write position in the underlying file. You should
always iterate over all entries until None
is returned if you want your next write to go
at the end; otherwise, you will write over existing entries.
Sourcepub fn aggregate_changesets(
&mut self,
) -> Result<Option<C>, AggregateChangesetsError<C>>
pub fn aggregate_changesets( &mut self, ) -> Result<Option<C>, AggregateChangesetsError<C>>
Loads all the changesets that have been stored as one giant changeset.
This function returns the aggregate changeset, or None
if nothing was persisted.
If reading or deserializing any of the entries fails, an error is returned that
consists of all those it was able to read.
You should usually check the error. In many applications, it may make sense to do a full wallet scan with a stop-gap after getting an error, since it is likely that one of the changesets was unable to read changes of the derivation indices of a keychain.
WARNING: This method changes the write position of the underlying file. The next changeset will be written over the erroring entry (or the end of the file if none existed).