@@ -26,7 +26,6 @@ use sqlx::{
2626 postgres:: { PgPool , Postgres } ,
2727 FromRow , Pool , Row , Transaction ,
2828} ;
29- use tokio:: sync:: Mutex ;
3029use tracing:: info;
3130
3231impl AsyncWalletPersister for Store < Postgres > {
@@ -58,7 +57,7 @@ impl Store<Postgres> {
5857 /// Construct a new [`Store`] with an existing pg connection.
5958 #[ tracing:: instrument]
6059 pub async fn new (
61- pool : Arc < Mutex < Pool < Postgres > > > ,
60+ pool : Pool < Postgres > ,
6261 wallet_name : Option < String > ,
6362 migration : bool ,
6463 ) -> Result < Self , BdkSqlxError > {
@@ -82,7 +81,6 @@ impl Store<Postgres> {
8281 info ! ( "new store with url" ) ;
8382
8483 let pool = PgPool :: connect ( url. as_str ( ) ) . await ?;
85- let pool = Arc :: new ( Mutex :: new ( pool) ) ;
8684 let wallet_name = wallet_name. unwrap_or_else ( || "bdk_pg_wallet" . to_string ( ) ) ;
8785
8886 Ok ( Self {
@@ -97,15 +95,14 @@ impl Store<Postgres> {
9795 #[ tracing:: instrument]
9896 pub ( crate ) async fn migrate_and_read ( & self ) -> Result < ChangeSet , BdkSqlxError > {
9997 info ! ( "migrate and read" ) ;
100- let pool = self . pool . lock ( ) . await ;
10198 if self . migration {
10299 let migrator = Migrator :: new ( std:: path:: Path :: new ( "./migrations/postgres/" ) )
103100 . await
104101 . unwrap ( ) ;
105- migrator. run ( & * pool) . await . unwrap ( ) ;
102+ migrator. run ( & self . pool ) . await . unwrap ( ) ;
106103 }
107104
108- let mut tx = pool. begin ( ) . await ?;
105+ let mut tx = self . pool . begin ( ) . await ?;
109106
110107 let mut changeset = ChangeSet :: default ( ) ;
111108
@@ -180,8 +177,7 @@ impl Store<Postgres> {
180177 }
181178
182179 let wallet_name = & self . wallet_name ;
183- let pool = self . pool . lock ( ) . await ;
184- let mut tx = pool. begin ( ) . await ?;
180+ let mut tx = self . pool . begin ( ) . await ?;
185181
186182 if let Some ( ref descriptor) = changeset. descriptor {
187183 insert_descriptor ( & mut tx, wallet_name, descriptor, External ) . await ?;
0 commit comments