@@ -1238,10 +1238,6 @@ impl<P: consensus::Parameters + Send + Sync + 'static> LightClient<P> {
12381238 /// Start syncing in batches with the max size, so we don't consume memory more than
12391239 // wha twe can handle.
12401240 async fn start_sync ( & self ) -> Result < JsonValue , String > {
1241- // We can only do one sync at a time because we sync blocks in serial order
1242- // If we allow multiple syncs, they'll all get jumbled up.
1243- let _lock = self . sync_lock . lock ( ) . await ;
1244-
12451241 // The top of the wallet
12461242 let last_scanned_height = self . wallet . last_scanned_height ( ) . await ;
12471243
@@ -1274,7 +1270,7 @@ impl<P: consensus::Parameters + Send + Sync + 'static> LightClient<P> {
12741270
12751271 // Re-read the last scanned height
12761272 let last_scanned_height = self . wallet . last_scanned_height ( ) . await ;
1277- let batch_size = 50_000 ;
1273+ let batch_size = 25_000 ;
12781274
12791275 let mut latest_block_batches = vec ! [ ] ;
12801276 let mut prev = last_scanned_height;
@@ -1297,7 +1293,14 @@ impl<P: consensus::Parameters + Send + Sync + 'static> LightClient<P> {
12971293
12981294 let mut res = Err ( "No batches were run!" . to_string ( ) ) ;
12991295 for ( batch_num, batch_latest_block) in latest_block_batches. into_iter ( ) . enumerate ( ) {
1300- res = self . start_sync_batch ( batch_latest_block, batch_num) . await ;
1296+ {
1297+ // We can only do one sync at a time because we sync blocks in serial order
1298+ // If we allow multiple syncs, they'll all get jumbled up.
1299+ let _lock = self . sync_lock . lock ( ) . await ;
1300+ res = self . start_sync_batch ( batch_latest_block, batch_num) . await ;
1301+ }
1302+
1303+ self . do_save ( ) . await ?;
13011304 if res. is_err ( ) {
13021305 return res;
13031306 }
0 commit comments