refactor: use tuple struct construction for SqliteStore type
This commit is contained in:
parent
f4366ac49f
commit
cddd5f25d8
@ -8,23 +8,19 @@ use bdk_wallet::KeychainKind;
|
|||||||
|
|
||||||
use std::sync::{Arc, Mutex, MutexGuard};
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
|
|
||||||
pub struct SqliteStore {
|
pub struct SqliteStore(Mutex<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>>);
|
||||||
inner_mutex: Mutex<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SqliteStore {
|
impl SqliteStore {
|
||||||
pub fn new(path: String) -> Result<Self, SqliteError> {
|
pub fn new(path: String) -> Result<Self, SqliteError> {
|
||||||
let connection = Connection::open(path)?;
|
let connection = Connection::open(path)?;
|
||||||
let db = Store::new(connection)?;
|
let db = Store::new(connection)?;
|
||||||
Ok(Self {
|
Ok(Self(Mutex::new(db)))
|
||||||
inner_mutex: Mutex::new(db),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_store(
|
pub(crate) fn get_store(
|
||||||
&self,
|
&self,
|
||||||
) -> MutexGuard<BdkSqliteStore<KeychainKind, ConfirmationTimeHeightAnchor>> {
|
) -> 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> {
|
pub fn write(&self, changeset: &ChangeSet) -> Result<(), SqliteError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user