anvil_polkadot/substrate_node/service/
consensus.rs1use polkadot_sdk::{
2 sc_consensus::BlockImportParams,
3 sc_consensus_aura::CompatibleDigestItem,
4 sc_consensus_manual_seal::{ConsensusDataProvider, Error},
5 sp_api::StorageProof,
6 sp_consensus_aura::ed25519::AuthoritySignature,
7 sp_consensus_babe::Slot,
8 sp_inherents::InherentData,
9 sp_runtime::{Digest, DigestItem, traits::Block as BlockT},
10};
11use std::marker::PhantomData;
12
13pub struct SameSlotConsensusDataProvider<B> {
21 _phantom: PhantomData<B>,
22}
23
24impl<B> SameSlotConsensusDataProvider<B> {
25 pub fn new() -> Self {
26 Self { _phantom: PhantomData }
27 }
28}
29
30impl<B> ConsensusDataProvider<B> for SameSlotConsensusDataProvider<B>
31where
32 B: BlockT,
33{
34 fn create_digest(
35 &self,
36 _parent: &B::Header,
37 _inherents: &InherentData,
38 ) -> Result<Digest, Error> {
39 let digest_item = <DigestItem as CompatibleDigestItem<AuthoritySignature>>::aura_pre_digest(
40 Slot::default(),
41 );
42
43 Ok(Digest { logs: vec![digest_item] })
44 }
45
46 fn append_block_import(
47 &self,
48 _parent: &B::Header,
49 _params: &mut BlockImportParams<B>,
50 _inherents: &InherentData,
51 _proof: StorageProof,
52 ) -> Result<(), Error> {
53 Ok(())
54 }
55}