@@ -286,15 +286,6 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
286
286
& mut self ,
287
287
reward_cycle : u64 ,
288
288
) -> Result < Option < SignerConfig > , ConfigurationError > {
289
- // We can only register for a reward cycle if its stackerdb has been updated
290
- let last_calculated_reward_cycle =
291
- self . stacks_client . get_last_set_cycle ( ) . inspect_err ( |e| {
292
- warn ! ( "Error while fetching last calculated reward cycle: {e:?}" ) ;
293
- } ) ?;
294
- if last_calculated_reward_cycle < reward_cycle as u128 {
295
- return Err ( ConfigurationError :: StackerDBNotUpdated ) ;
296
- }
297
-
298
289
// We can only register for a reward cycle if a reward set exists.
299
290
let signer_entries = match self . get_parsed_reward_set ( reward_cycle) {
300
291
Ok ( Some ( x) ) => x,
@@ -304,6 +295,25 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
304
295
return Err ( e. into ( ) ) ;
305
296
}
306
297
} ;
298
+
299
+ // Ensure that the stackerdb has been updated for the reward cycle before proceeding
300
+ retry_with_exponential_backoff ( || {
301
+ let last_calculated_reward_cycle = self
302
+ . stacks_client
303
+ . get_last_set_cycle ( )
304
+ . map_err ( |e| backoff:: Error :: transient ( e. into ( ) ) ) ?;
305
+ if last_calculated_reward_cycle < reward_cycle as u128 {
306
+ warn ! (
307
+ "Stackerdb has not been updated for reward cycle {reward_cycle}. Last calculated reward cycle is {last_calculated_reward_cycle}."
308
+ ) ;
309
+ Err ( backoff:: Error :: transient (
310
+ ConfigurationError :: StackerDBNotUpdated ,
311
+ ) )
312
+ } else {
313
+ Ok ( ( ) )
314
+ }
315
+ } ) ?;
316
+
307
317
let signer_slot_ids = match self . get_parsed_signer_slots ( & self . stacks_client , reward_cycle)
308
318
{
309
319
Ok ( x) => x,
0 commit comments