@@ -66,22 +66,29 @@ impl UtxoIndexProxy {
6666 Self { inner }
6767 }
6868
69- pub async fn get_circulating_supply ( self ) -> StoreResult < u64 > {
70- spawn_blocking ( move || self . inner . read ( ) . get_circulating_supply ( ) ) . await . unwrap ( )
69+ pub async fn get_circulating_supply ( & self ) -> StoreResult < u64 > {
70+ let inner = Arc :: clone ( & self . inner ) ;
71+ spawn_blocking ( move || inner. read ( ) . get_circulating_supply ( ) ) . await . unwrap ( )
7172 }
7273
73- pub async fn get_utxos_by_script_public_keys ( self , script_public_keys : ScriptPublicKeys ) -> StoreResult < UtxoSetByScriptPublicKey > {
74- spawn_blocking ( move || self . inner . read ( ) . get_utxos_by_script_public_keys ( script_public_keys) ) . await . unwrap ( )
74+ pub async fn get_utxos_by_script_public_keys (
75+ & self ,
76+ script_public_keys : ScriptPublicKeys ,
77+ ) -> StoreResult < UtxoSetByScriptPublicKey > {
78+ let inner = Arc :: clone ( & self . inner ) ;
79+ spawn_blocking ( move || inner. read ( ) . get_utxos_by_script_public_keys ( script_public_keys) ) . await . unwrap ( )
7580 }
7681
7782 pub async fn get_balance_by_script_public_keys (
78- self ,
83+ & self ,
7984 script_public_keys : ScriptPublicKeys ,
8085 ) -> StoreResult < BalanceByScriptPublicKey > {
81- spawn_blocking ( move || self . inner . read ( ) . get_balance_by_script_public_keys ( script_public_keys) ) . await . unwrap ( )
86+ let inner = Arc :: clone ( & self . inner ) ;
87+ spawn_blocking ( move || inner. read ( ) . get_balance_by_script_public_keys ( script_public_keys) ) . await . unwrap ( )
8288 }
8389
84- pub async fn update ( self , utxo_diff : Arc < UtxoDiff > , tips : Arc < Vec < Hash > > ) -> UtxoIndexResult < UtxoChanges > {
85- spawn_blocking ( move || self . inner . write ( ) . update ( utxo_diff, tips) ) . await . unwrap ( )
90+ pub async fn update ( & self , utxo_diff : Arc < UtxoDiff > , tips : Arc < Vec < Hash > > ) -> UtxoIndexResult < UtxoChanges > {
91+ let inner = Arc :: clone ( & self . inner ) ;
92+ spawn_blocking ( move || inner. write ( ) . update ( utxo_diff, tips) ) . await . unwrap ( )
8693 }
8794}
0 commit comments