@@ -306,13 +306,8 @@ pub trait BillServiceApi: Send + Sync {
306
306
/// Gets the bill for the given bill id
307
307
async fn get_bill ( & self , bill_id : & str ) -> Result < BitcreditBill > ;
308
308
309
- /// Try to get the given bill from the dht and saves it locally, if found
310
- async fn find_bill_in_dht (
311
- & self ,
312
- bill_id : & str ,
313
- caller_public_data : & IdentityPublicData ,
314
- caller_keys : & BcrKeys ,
315
- ) -> Result < ( ) > ;
309
+ /// Try to get the given bill chain from the dht and sync the blocks, if found
310
+ async fn find_and_sync_with_bill_in_dht ( & self , bill_id : & str ) -> Result < ( ) > ;
316
311
317
312
/// Gets the keys for a given bill
318
313
async fn get_bill_keys ( & self , bill_id : & str ) -> Result < BillKeys > ;
@@ -1930,20 +1925,12 @@ impl BillServiceApi for BillService {
1930
1925
Ok ( bill)
1931
1926
}
1932
1927
1933
- async fn find_bill_in_dht (
1934
- & self ,
1935
- bill_id : & str ,
1936
- caller_public_data : & IdentityPublicData ,
1937
- caller_keys : & BcrKeys ,
1938
- ) -> Result < ( ) > {
1939
- self . client
1940
- . clone ( )
1941
- . get_bill_data_from_the_network (
1942
- bill_id,
1943
- & caller_public_data. node_id ,
1944
- & caller_keys. get_private_key_string ( ) ,
1945
- )
1946
- . await ?;
1928
+ async fn find_and_sync_with_bill_in_dht ( & self , bill_id : & str ) -> Result < ( ) > {
1929
+ if !self . store . exists ( bill_id) . await {
1930
+ return Err ( Error :: NotFound ) ;
1931
+ }
1932
+ let mut dht_client = self . client . clone ( ) ;
1933
+ dht_client. receive_updates_for_bill_topic ( bill_id) . await ?;
1947
1934
Ok ( ( ) )
1948
1935
}
1949
1936
0 commit comments