mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
removes use of sc_client::Client from sc_network (#5147)
* removes use of sc_client::Client from sc_network * rename BlockProvider to BlockBackend * fix broken test
This commit is contained in:
@@ -71,7 +71,7 @@ pub use sc_client_api::{
|
||||
},
|
||||
client::{
|
||||
ImportNotifications, FinalityNotification, FinalityNotifications, BlockImportNotification,
|
||||
ClientInfo, BlockchainEvents, BlockBody, ProvideUncles, BadBlocks, ForkBlocks,
|
||||
ClientInfo, BlockchainEvents, BlockBackend, ProvideUncles, BadBlocks, ForkBlocks,
|
||||
BlockOf,
|
||||
},
|
||||
execution_extensions::{ExecutionExtensions, ExecutionStrategies},
|
||||
@@ -1058,11 +1058,6 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
self.backend.blockchain().body(*id)
|
||||
}
|
||||
|
||||
/// Get block justification set by id.
|
||||
pub fn justification(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<Justification>> {
|
||||
self.backend.blockchain().justification(*id)
|
||||
}
|
||||
|
||||
/// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
|
||||
pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>) -> sp_blockchain::Result<Vec<Block::Hash>> {
|
||||
let load_header = |id: Block::Hash| -> sp_blockchain::Result<Block::Header> {
|
||||
@@ -1865,7 +1860,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> BlockBody<Block> for Client<B, E, Block, RA>
|
||||
impl<B, E, Block, RA> BlockBackend<Block> for Client<B, E, Block, RA>
|
||||
where
|
||||
B: backend::Backend<Block>,
|
||||
E: CallExecutor<Block>,
|
||||
@@ -1886,6 +1881,33 @@ impl<B, E, Block, RA> BlockBody<Block> for Client<B, E, Block, RA>
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn block_status(&self, id: &BlockId<Block>) -> sp_blockchain::Result<BlockStatus> {
|
||||
// this can probably be implemented more efficiently
|
||||
if let BlockId::Hash(ref h) = id {
|
||||
if self.importing_block.read().as_ref().map_or(false, |importing| h == importing) {
|
||||
return Ok(BlockStatus::Queued);
|
||||
}
|
||||
}
|
||||
let hash_and_number = match id.clone() {
|
||||
BlockId::Hash(hash) => self.backend.blockchain().number(hash)?.map(|n| (hash, n)),
|
||||
BlockId::Number(n) => self.backend.blockchain().hash(n)?.map(|hash| (hash, n)),
|
||||
};
|
||||
match hash_and_number {
|
||||
Some((hash, number)) => {
|
||||
if self.backend.have_state_at(&hash, number) {
|
||||
Ok(BlockStatus::InChainWithState)
|
||||
} else {
|
||||
Ok(BlockStatus::InChainPruned)
|
||||
}
|
||||
}
|
||||
None => Ok(BlockStatus::Unknown),
|
||||
}
|
||||
}
|
||||
|
||||
fn justification(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<Justification>> {
|
||||
self.backend.blockchain().justification(*id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> backend::AuxStore for Client<B, E, Block, RA>
|
||||
|
||||
@@ -98,7 +98,7 @@ pub use crate::{
|
||||
client::{
|
||||
new_with_backend,
|
||||
new_in_mem,
|
||||
BlockBody, ImportNotifications, FinalityNotifications, BlockchainEvents, LockImportRun,
|
||||
BlockBackend, ImportNotifications, FinalityNotifications, BlockchainEvents, LockImportRun,
|
||||
BlockImportNotification, Client, ClientInfo, ExecutionStrategies, FinalityNotification,
|
||||
LongestChain, BlockOf, ProvideUncles, BadBlocks, ForkBlocks, apply_aux,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user