This repository was archived by the owner on Feb 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ impl<S: MutinyStorage> HermesClient<S> {
159159 let current_address_check_clone = self . current_address . clone ( ) ;
160160 let first_federation = self . get_first_federation ( ) . await . clone ( ) ;
161161 utils:: spawn ( async move {
162+ let mut count = 1 ;
162163 loop {
163164 if stop_check_clone. load ( Ordering :: Relaxed ) {
164165 break ;
@@ -263,7 +264,10 @@ impl<S: MutinyStorage> HermesClient<S> {
263264 }
264265 } ;
265266
266- utils:: sleep ( 1_000 ) . await ;
267+ // exponential backoff
268+ let sleep_time = std:: cmp:: min ( 1_000 * ( 2_i32 . pow ( count) ) , 60_000 ) ;
269+ utils:: sleep ( sleep_time) . await ;
270+ count += 1 ;
267271 }
268272 } ) ;
269273
Original file line number Diff line number Diff line change @@ -1482,12 +1482,17 @@ impl<S: MutinyStorage> MutinyWallet<S> {
14821482 let self_clone = self . clone ( ) ;
14831483 utils:: spawn ( async move {
14841484 // keep trying until it succeeds
1485+ let mut count = 1 ;
14851486 loop {
14861487 match self_clone. sync_nostr ( ) . await {
14871488 Ok ( _) => break ,
14881489 Err ( e) => {
14891490 log_error ! ( self_clone. logger, "Failed to sync nostr: {e}" ) ;
1490- sleep ( 5_000 ) . await ;
1491+
1492+ // exponential backoff
1493+ let sleep_time = std:: cmp:: min ( 1_000 * ( 2_i32 . pow ( count) ) , 60_000 ) ;
1494+ sleep ( sleep_time) . await ;
1495+ count += 1 ;
14911496 }
14921497 }
14931498
You can’t perform that action at this time.
0 commit comments