Skip to content

Delegate rustqlite connection persister to transaction persister #1863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions crates/wallet/src/wallet/persisted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,15 @@ impl WalletPersister for bdk_chain::rusqlite::Connection {
type Error = bdk_chain::rusqlite::Error;

fn initialize(persister: &mut Self) -> Result<ChangeSet, Self::Error> {
let db_tx = persister.transaction()?;
ChangeSet::init_sqlite_tables(&db_tx)?;
let changeset = ChangeSet::from_sqlite(&db_tx)?;
let mut db_tx = persister.transaction()?;
let changeset = WalletPersister::initialize(&mut db_tx)?;
db_tx.commit()?;
Ok(changeset)
}

fn persist(persister: &mut Self, changeset: &ChangeSet) -> Result<(), Self::Error> {
let db_tx = persister.transaction()?;
changeset.persist_to_sqlite(&db_tx)?;
let mut db_tx = persister.transaction()?;
WalletPersister::persist(&mut db_tx, changeset)?;
db_tx.commit()
}
}
Expand Down
Loading