feat(bdk-persist): extract persistence traits to new crate

This commit is contained in:
Rob N
2024-04-24 15:01:17 -10:00
parent 8e73998cfa
commit 81de8f6051
18 changed files with 52 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ readme = "README.md"
[dependencies]
anyhow = { version = "1", default-features = false }
bdk_chain = { path = "../chain", version = "0.12.0", features = [ "serde", "miniscript" ] }
bdk_persist = { path = "../persist", version = "0.1.0"}
bincode = { version = "1" }
serde = { version = "1", features = ["derive"] }

View File

@@ -1,10 +1,10 @@
# BDK File Store
This is a simple append-only flat file implementation of
[`Persist`](`bdk_chain::Persist`).
[`PersistBackend`](bdk_persist::PersistBackend).
The main structure is [`Store`](`crate::Store`), which can be used with [`bdk`]'s
The main structure is [`Store`](crate::Store), which can be used with [`bdk`]'s
`Wallet` to persist wallet data into a flat file.
[`bdk`]: https://docs.rs/bdk/latest
[`bdk_chain`]: https://docs.rs/bdk_chain/latest
[`bdk_persist`]: https://docs.rs/bdk_persist/latest

View File

@@ -1,6 +1,7 @@
use crate::{bincode_options, EntryIter, FileError, IterError};
use anyhow::anyhow;
use bdk_chain::{Append, PersistBackend};
use bdk_chain::Append;
use bdk_persist::PersistBackend;
use bincode::Options;
use std::{
fmt::{self, Debug},
@@ -11,8 +12,6 @@ use std::{
};
/// Persists an append-only list of changesets (`C`) to a single file.
///
/// The changesets are the results of altering a tracker implementation (`T`).
#[derive(Debug)]
pub struct Store<C>
where
@@ -152,7 +151,7 @@ where
///
/// 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 it was unable to read changed the derivation indices of the tracker.
/// 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).
@@ -240,9 +239,6 @@ mod test {
type TestChangeSet = BTreeSet<String>;
#[derive(Debug)]
struct TestTracker;
/// Check behavior of [`Store::create_new`] and [`Store::open`].
#[test]
fn construct_store() {