Relax types on DigestItemRef, such that byte slices can be used in addition to vector references (#10536)

* Relax types on `DigestItemRef`, such that byte slices can be used in addition to vector references

* Apply clippy suggestions
This commit is contained in:
Nazar Mokrynskyi
2022-01-20 12:02:22 +02:00
committed by GitHub
parent 1344e43d2d
commit 6b60c3dbff
159 changed files with 164 additions and 164 deletions
@@ -177,16 +177,16 @@ pub enum DigestItemRef<'a> {
/// the consensus engine can (and should) read them itself to avoid
/// code and state duplication. It is erroneous for a runtime to produce
/// these, but this is not (yet) checked.
PreRuntime(&'a ConsensusEngineId, &'a Vec<u8>),
PreRuntime(&'a ConsensusEngineId, &'a [u8]),
/// A message from the runtime to the consensus engine. This should *never*
/// be generated by the native code of any consensus engine, but this is not
/// checked (yet).
Consensus(&'a ConsensusEngineId, &'a Vec<u8>),
Consensus(&'a ConsensusEngineId, &'a [u8]),
/// Put a Seal on it. This is only used by native code, and is never seen
/// by runtimes.
Seal(&'a ConsensusEngineId, &'a Vec<u8>),
Seal(&'a ConsensusEngineId, &'a [u8]),
/// Any 'non-system' digest item, opaque to the native code.
Other(&'a Vec<u8>),
Other(&'a [u8]),
/// Runtime code or heap pages updated.
RuntimeEnvironmentUpdated,
}
@@ -358,8 +358,8 @@ impl<'a> DigestItemRef<'a> {
(OpaqueDigestItemId::Seal(w), &Self::Seal(v, s)) |
(OpaqueDigestItemId::PreRuntime(w), &Self::PreRuntime(v, s))
if v == w =>
Some(&s[..]),
(OpaqueDigestItemId::Other, &Self::Other(s)) => Some(&s[..]),
Some(s),
(OpaqueDigestItemId::Other, &Self::Other(s)) => Some(s),
_ => None,
}
}