polkadot_node_core_provisioner/disputes/mod.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! The disputes module is responsible for selecting dispute votes to be sent with the inherent
18//! data.
19
20use crate::LOG_TARGET;
21use futures::channel::oneshot;
22use polkadot_node_primitives::CandidateVotes;
23use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer};
24use polkadot_primitives::{CandidateHash, SessionIndex};
25
26/// Request the relevant dispute statements for a set of disputes identified by `CandidateHash` and
27/// the `SessionIndex`.
28async fn request_votes(
29 sender: &mut impl overseer::ProvisionerSenderTrait,
30 disputes_to_query: Vec<(SessionIndex, CandidateHash)>,
31) -> Vec<(SessionIndex, CandidateHash, CandidateVotes)> {
32 let (tx, rx) = oneshot::channel();
33 // Bounded by block production - `ProvisionerMessage::RequestInherentData`.
34 sender.send_unbounded_message(DisputeCoordinatorMessage::QueryCandidateVotes(
35 disputes_to_query,
36 tx,
37 ));
38
39 match rx.await {
40 Ok(v) => v,
41 Err(oneshot::Canceled) => {
42 gum::warn!(target: LOG_TARGET, "Unable to query candidate votes");
43 Vec::new()
44 },
45 }
46}
47
48pub(crate) mod prioritized_selection;