mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
removes use of sc_client::Client from sc-rpc (#5063)
* removes use of sc_client::Client from sc-rpc * remove Client impl from sc-finality-benches * remove client impl from sc-finality-grandpa * read_proof accepts iterator * remove generic Executor param from ExecutorProvider * fix long ass line * code style changes * merge with master Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
dc85ccb7df
commit
99ae5342eb
@@ -34,16 +34,15 @@
|
||||
//! finality proof (that finalizes some block C that is ancestor of the B and descendant
|
||||
//! of the U) could be returned.
|
||||
|
||||
use std::iter;
|
||||
use std::sync::Arc;
|
||||
use log::{trace, warn};
|
||||
|
||||
use sp_blockchain::{Backend as BlockchainBackend, Error as ClientError, Result as ClientResult};
|
||||
use sc_client_api::{
|
||||
backend::Backend, CallExecutor, StorageProof,
|
||||
backend::Backend, StorageProof,
|
||||
light::{FetchChecker, RemoteReadRequest},
|
||||
StorageProvider, ProofProvider,
|
||||
};
|
||||
use sc_client::Client;
|
||||
use parity_scale_codec::{Encode, Decode};
|
||||
use finality_grandpa::BlockNumberOps;
|
||||
use sp_runtime::{
|
||||
@@ -67,12 +66,25 @@ pub trait AuthoritySetForFinalityProver<Block: BlockT>: Send + Sync {
|
||||
fn prove_authorities(&self, block: &BlockId<Block>) -> ClientResult<StorageProof>;
|
||||
}
|
||||
|
||||
/// Client-based implementation of AuthoritySetForFinalityProver.
|
||||
impl<B, E, Block: BlockT, RA> AuthoritySetForFinalityProver<Block> for Client<B, E, Block, RA>
|
||||
/// Trait that combines `StorageProvider` and `ProofProvider`
|
||||
pub trait StorageAndProofProvider<Block, BE>: StorageProvider<Block, BE> + ProofProvider<Block> + Send + Sync
|
||||
where
|
||||
B: Backend<Block> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block> + 'static + Clone + Send + Sync,
|
||||
RA: Send + Sync,
|
||||
Block: BlockT,
|
||||
BE: Backend<Block> + Send + Sync,
|
||||
{}
|
||||
|
||||
/// Blanket implementation.
|
||||
impl<Block, BE, P> StorageAndProofProvider<Block, BE> for P
|
||||
where
|
||||
Block: BlockT,
|
||||
BE: Backend<Block> + Send + Sync,
|
||||
P: StorageProvider<Block, BE> + ProofProvider<Block> + Send + Sync,
|
||||
{}
|
||||
|
||||
/// Implementation of AuthoritySetForFinalityProver.
|
||||
impl<BE, Block: BlockT> AuthoritySetForFinalityProver<Block> for Arc<dyn StorageAndProofProvider<Block, BE>>
|
||||
where
|
||||
BE: Backend<Block> + Send + Sync + 'static,
|
||||
{
|
||||
fn authorities(&self, block: &BlockId<Block>) -> ClientResult<AuthorityList> {
|
||||
let storage_key = StorageKey(GRANDPA_AUTHORITIES_KEY.to_vec());
|
||||
@@ -83,7 +95,7 @@ impl<B, E, Block: BlockT, RA> AuthoritySetForFinalityProver<Block> for Client<B,
|
||||
}
|
||||
|
||||
fn prove_authorities(&self, block: &BlockId<Block>) -> ClientResult<StorageProof> {
|
||||
self.read_proof(block, iter::once(GRANDPA_AUTHORITIES_KEY))
|
||||
self.read_proof(block, &mut std::iter::once(GRANDPA_AUTHORITIES_KEY))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +158,13 @@ impl<B, Block: BlockT> FinalityProofProvider<B, Block>
|
||||
///
|
||||
/// - backend for accessing blockchain data;
|
||||
/// - authority_provider for calling and proving runtime methods.
|
||||
pub fn new(
|
||||
pub fn new<P>(
|
||||
backend: Arc<B>,
|
||||
authority_provider: Arc<dyn AuthoritySetForFinalityProver<Block>>,
|
||||
) -> Self {
|
||||
FinalityProofProvider { backend, authority_provider }
|
||||
authority_provider: P,
|
||||
) -> Self
|
||||
where P: AuthoritySetForFinalityProver<Block> + 'static,
|
||||
{
|
||||
FinalityProofProvider { backend, authority_provider: Arc::new(authority_provider) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user