diff --git a/node/core/approval-voting/src/lib.rs b/node/core/approval-voting/src/lib.rs index 342fc0341b99..ac025f366ab7 100644 --- a/node/core/approval-voting/src/lib.rs +++ b/node/core/approval-voting/src/lib.rs @@ -1210,8 +1210,24 @@ async fn get_approval_signatures_for_candidate( candidate_hash: CandidateHash, tx: oneshot::Sender>, ) -> SubsystemResult<()> { + let send_votes = |votes| { + if let Err(_) = tx.send(votes) { + gum::debug!( + target: LOG_TARGET, + "Sending approval signatures back failed, as receiver got closed." + ); + } + }; let entry = match db.load_candidate_entry(&candidate_hash)? { - None => return Ok(()), + None => { + send_votes(HashMap::new()); + gum::debug!( + target: LOG_TARGET, + ?candidate_hash, + "Sent back empty votes because the candidate was not found in db." + ); + return Ok(()) + }, Some(e) => e, }; @@ -1261,13 +1277,7 @@ async fn get_approval_signatures_for_candidate( target: LOG_TARGET, "Request for approval signatures got cancelled by `approval-distribution`." ), - Some(Ok(votes)) => - if let Err(_) = tx.send(votes) { - gum::debug!( - target: LOG_TARGET, - "Sending approval signatures back failed, as receiver got closed" - ); - }, + Some(Ok(votes)) => send_votes(votes), } };