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>
This commit is contained in:
Robert Klotzner
2022-08-24 17:44:13 +02:00
committed by GitHub
parent 126758429b
commit c83eaa2475
+18 -8
View File
@@ -1210,8 +1210,24 @@ async fn get_approval_signatures_for_candidate<Context>(
candidate_hash: CandidateHash,
tx: oneshot::Sender<HashMap<ValidatorIndex, ValidatorSignature>>,
) -> 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<Context>(
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),
}
};