use sc_client_api::ProvideUncles;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
#[derive(Debug, thiserror::Error)]
pub enum Error<B: BlockT> {
#[error("Could not retrieve the block hash for block id: {0:?}")]
NoHashForBlockId(BlockId<B>),
}
const MAX_UNCLE_GENERATIONS: u32 = 8;
pub fn create_uncles_inherent_data_provider<B, C>(
client: &C,
parent: B::Hash,
) -> Result<sp_authorship::InherentDataProvider<B::Header>, sc_client_api::blockchain::Error>
where
B: BlockT,
C: ProvideUncles<B>,
{
let uncles = client.uncles(parent, MAX_UNCLE_GENERATIONS.into())?;
Ok(sp_authorship::InherentDataProvider::new(uncles))
}