#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use sp_runtime::{ConsensusEngineId, DigestItem};
const DOMAIN_REGISTRY_ENGINE_ID: ConsensusEngineId = *b"RGTR";
pub trait AsPredigest {
fn as_consensus_block_info<Hash: Decode>(&self) -> Option<Hash>;
fn consensus_block_info<Hash: Encode>(consensus_block_hash: Hash) -> Self;
}
impl AsPredigest for DigestItem {
fn as_consensus_block_info<Hash: Decode>(&self) -> Option<Hash> {
self.pre_runtime_try_to(&DOMAIN_REGISTRY_ENGINE_ID)
}
fn consensus_block_info<Hash: Encode>(consensus_block_hash: Hash) -> Self {
DigestItem::PreRuntime(DOMAIN_REGISTRY_ENGINE_ID, consensus_block_hash.encode())
}
}