Skip to content

Commit bbc00fd

Browse files
committed
Do not create the wallet struct directly; instead, call new.
The bug comes with the SQLx-sqlite pool bug, where several connections are created by default, but the `new` function takes care of that, fixing that bug by making a single instance of the database. If constructed directly, the pool would create several connections to the database, which in most instances is fine, but with SQLite :memory: each connection is entirely independent.
1 parent f0766d0 commit bbc00fd

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/cdk-sqlite/src/wallet/memory.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ use super::WalletSqliteDatabase;
66

77
/// Creates a new in-memory [`WalletSqliteDatabase`] instance
88
pub async fn empty() -> Result<WalletSqliteDatabase, Error> {
9-
let db = WalletSqliteDatabase {
10-
pool: sqlx::sqlite::SqlitePool::connect(":memory:")
11-
.await
12-
.map_err(|e| Error::Database(Box::new(e)))?,
13-
};
9+
let db = WalletSqliteDatabase::new(":memory:").await?;
1410
db.migrate().await;
1511
Ok(db)
1612
}

0 commit comments

Comments
 (0)