Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Send back empty votes + log in approval-voting in case candidate entry is missing. #5925

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"Votes got requested, but candidate was not found in db."
eskimor marked this conversation as resolved.
Show resolved Hide resolved
);
return Ok(())
},
Some(e) => e,
};

Expand Down Expand Up @@ -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),
}
};

Expand Down