mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 01:11:10 +00:00
Set uncles inherent (#3317)
* Include uncles * Filter missing uncles * Moved inherent registration to a new crate * Ignore invalid inherent encoding
This commit is contained in:
@@ -170,6 +170,13 @@ pub trait BlockBody<Block: BlockT> {
|
||||
) -> error::Result<Option<Vec<<Block as BlockT>::Extrinsic>>>;
|
||||
}
|
||||
|
||||
/// Provide a list of potential uncle headers for a given block.
|
||||
pub trait ProvideUncles<Block: BlockT> {
|
||||
/// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
|
||||
fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>)
|
||||
-> error::Result<Vec<Block::Header>>;
|
||||
}
|
||||
|
||||
/// Client info
|
||||
#[derive(Debug)]
|
||||
pub struct ClientInfo<Block: BlockT> {
|
||||
@@ -1329,7 +1336,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
ancestor_hash = *current.parent_hash();
|
||||
ancestor = load_header(ancestor_hash)?;
|
||||
}
|
||||
|
||||
trace!("Collected {} uncles", uncles.len());
|
||||
Ok(uncles)
|
||||
}
|
||||
|
||||
@@ -1353,6 +1360,20 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> ProvideUncles<Block> for Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CallExecutor<Block, Blake2Hasher>,
|
||||
Block: BlockT<Hash=H256>,
|
||||
{
|
||||
fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>) -> error::Result<Vec<Block::Header>> {
|
||||
Ok(Client::uncles(self, target_hash, max_generation)?
|
||||
.into_iter()
|
||||
.filter_map(|hash| Client::header(self, &BlockId::Hash(hash)).unwrap_or(None))
|
||||
.collect()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> ChainHeaderBackend<Block> for Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync,
|
||||
|
||||
@@ -115,7 +115,7 @@ pub use crate::client::{
|
||||
new_in_mem,
|
||||
BlockBody, BlockStatus, ImportNotifications, FinalityNotifications, BlockchainEvents,
|
||||
BlockImportNotification, Client, ClientInfo, ExecutionStrategies, FinalityNotification,
|
||||
LongestChain, BlockOf,
|
||||
LongestChain, BlockOf, ProvideUncles,
|
||||
utils,
|
||||
};
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
Reference in New Issue
Block a user