From c83eaa24753e1263569ff4a2a340290acc2bcf47 Mon Sep 17 00:00:00 2001 From: Robert Klotzner Date: Wed, 24 Aug 2022 17:44:13 +0200 Subject: [PATCH] Send back empty votes + log in approval-voting in case candidate entry is missing. (#5925) * Send back empty votes + log. * Update node/core/approval-voting/src/lib.rs Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> --- polkadot/node/core/approval-voting/src/lib.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/polkadot/node/core/approval-voting/src/lib.rs b/polkadot/node/core/approval-voting/src/lib.rs index 342fc0341b..ac025f366a 100644 --- a/polkadot/node/core/approval-voting/src/lib.rs +++ b/polkadot/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), } };