diff --git a/state-chain/pallets/cf-broadcast/src/lib.rs b/state-chain/pallets/cf-broadcast/src/lib.rs index d787a65b1d..5712e36f3e 100644 --- a/state-chain/pallets/cf-broadcast/src/lib.rs +++ b/state-chain/pallets/cf-broadcast/src/lib.rs @@ -452,10 +452,7 @@ pub mod pallet { .broadcast_id, }); } else { - BroadcastRetryQueue::::append(&signing_attempt.broadcast_attempt); - Self::deposit_event(Event::::BroadcastRetryScheduled { - broadcast_attempt_id: signing_attempt.broadcast_attempt.broadcast_attempt_id, - }); + Self::schedule_for_retry(&signing_attempt.broadcast_attempt); } Ok(().into()) @@ -721,10 +718,12 @@ impl, I: 'static> Pallet { let next_broadcast_attempt_id = broadcast_attempt.broadcast_attempt_id.next_attempt(); - BroadcastAttemptCount::::mutate(broadcast_id, |attempt_count| { - *attempt_count += 1; - *attempt_count - }); + BroadcastAttemptCount::::mutate( + broadcast_id, + |attempt_count: &mut AttemptCount| { + *attempt_count += 1; + }, + ); debug_assert_eq!( BroadcastAttemptCount::::get(broadcast_id), next_broadcast_attempt_id.attempt_count, @@ -790,12 +789,20 @@ impl, I: 'static> Pallet { transaction_out_id: broadcast_attempt.transaction_out_id, }); } else { - const FAILED_SIGNER_SELECTION: &str = "Failed to select signer: We should either: a) have a signer eligible for nomination b) already have aborted this broadcast when scheduling the retry"; - log::error!("{FAILED_SIGNER_SELECTION}"); - #[cfg(test)] - panic!("{FAILED_SIGNER_SELECTION}"); + log::warn!( + "Failed to select a signer for broadcast {:?}. Scheduling Retry", + broadcast_attempt.broadcast_attempt_id + ); + Self::schedule_for_retry(&broadcast_attempt); } } + + fn schedule_for_retry(broadcast_attempt: &BroadcastAttempt) { + BroadcastRetryQueue::::append(broadcast_attempt); + Self::deposit_event(Event::::BroadcastRetryScheduled { + broadcast_attempt_id: broadcast_attempt.broadcast_attempt_id, + }); + } } impl, I: 'static> Broadcaster for Pallet {