Skip to content

Commit

Permalink
refactor: use tuple struct construction for SqliteStore type
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Jun 27, 2024
1 parent f4366ac commit cddd5f2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions bdk-ffi/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ use bdk_wallet::KeychainKind;

use std::sync::{Arc, Mutex, MutexGuard};

pub struct SqliteStore {
inner_mutex: Mutex<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>>,
}
pub struct SqliteStore(Mutex<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>>);

impl SqliteStore {
pub fn new(path: String) -> Result<Self, SqliteError> {
let connection = Connection::open(path)?;
let db = Store::new(connection)?;
Ok(Self {
inner_mutex: Mutex::new(db),
})
Ok(Self(Mutex::new(db)))
}

pub(crate) fn get_store(
&self,
) -> MutexGuard<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>> {
self.inner_mutex.lock().expect("sqlite store")
self.0.lock().expect("sqlite store")
}

pub fn write(&self, changeset: &ChangeSet) -> Result<(), SqliteError> {
Expand Down

0 comments on commit cddd5f2

Please sign in to comment.