mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 16:01:04 +00:00
Make CandidateHash a real type (#1916)
* Make `CandidateHash` a real type This pr adds a new type `CandidateHash` that is used instead of the opaque `Hash` type. This helps to ensure on the type system level that we are passing the correct types. This pr also fixes wrong usage of `relay_parent` as `candidate_hash` when communicating with the av storage. * Update core-primitives/src/lib.rs Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> * Wrap the lines Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
This commit is contained in:
@@ -18,63 +18,21 @@ pub mod generic;
|
||||
|
||||
pub use generic::{Table, Context};
|
||||
|
||||
/// Concrete instantiations suitable for v0 primitives.
|
||||
pub mod v0 {
|
||||
use crate::generic;
|
||||
use primitives::v0::{
|
||||
Hash,
|
||||
Id, AbridgedCandidateReceipt, CompactStatement as PrimitiveStatement, ValidatorSignature, ValidatorIndex,
|
||||
};
|
||||
|
||||
/// Statements about candidates on the network.
|
||||
pub type Statement = generic::Statement<AbridgedCandidateReceipt, Hash>;
|
||||
|
||||
/// Signed statements about candidates.
|
||||
pub type SignedStatement = generic::SignedStatement<
|
||||
AbridgedCandidateReceipt,
|
||||
Hash,
|
||||
ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
>;
|
||||
|
||||
/// Kinds of misbehavior, along with proof.
|
||||
pub type Misbehavior = generic::Misbehavior<
|
||||
AbridgedCandidateReceipt,
|
||||
Hash,
|
||||
ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
>;
|
||||
|
||||
/// A summary of import of a statement.
|
||||
pub type Summary = generic::Summary<Hash, Id>;
|
||||
|
||||
impl<'a> From<&'a Statement> for PrimitiveStatement {
|
||||
fn from(s: &'a Statement) -> PrimitiveStatement {
|
||||
match *s {
|
||||
generic::Statement::Valid(s) => PrimitiveStatement::Valid(s),
|
||||
generic::Statement::Invalid(s) => PrimitiveStatement::Invalid(s),
|
||||
generic::Statement::Candidate(ref s) => PrimitiveStatement::Candidate(s.hash()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Concrete instantiations suitable for v1 primitives.
|
||||
pub mod v1 {
|
||||
use crate::generic;
|
||||
use primitives::v1::{
|
||||
Hash,
|
||||
Id, CommittedCandidateReceipt, CompactStatement as PrimitiveStatement,
|
||||
CandidateHash, Id, CommittedCandidateReceipt, CompactStatement as PrimitiveStatement,
|
||||
ValidatorSignature, ValidatorIndex,
|
||||
};
|
||||
|
||||
/// Statements about candidates on the network.
|
||||
pub type Statement = generic::Statement<CommittedCandidateReceipt, Hash>;
|
||||
pub type Statement = generic::Statement<CommittedCandidateReceipt, CandidateHash>;
|
||||
|
||||
/// Signed statements about candidates.
|
||||
pub type SignedStatement = generic::SignedStatement<
|
||||
CommittedCandidateReceipt,
|
||||
Hash,
|
||||
CandidateHash,
|
||||
ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
>;
|
||||
@@ -82,13 +40,13 @@ pub mod v1 {
|
||||
/// Kinds of misbehavior, along with proof.
|
||||
pub type Misbehavior = generic::Misbehavior<
|
||||
CommittedCandidateReceipt,
|
||||
Hash,
|
||||
CandidateHash,
|
||||
ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
>;
|
||||
|
||||
/// A summary of import of a statement.
|
||||
pub type Summary = generic::Summary<Hash, Id>;
|
||||
pub type Summary = generic::Summary<CandidateHash, Id>;
|
||||
|
||||
impl<'a> From<&'a Statement> for PrimitiveStatement {
|
||||
fn from(s: &'a Statement) -> PrimitiveStatement {
|
||||
|
||||
Reference in New Issue
Block a user