Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
removes use of sc_client::Client from sc_finality_grandpa
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Feb 26, 2020
1 parent 2c0eafd commit 4907e0b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ pub trait BlockImportOperation<Block: BlockT> {
fn mark_head(&mut self, id: BlockId<Block>) -> sp_blockchain::Result<()>;
}

/// trait for performing operations on the backend
pub trait ClientBackend<Block: BlockT, B: Backend<Block>> {
/// Interface for performing operations on the backend.
pub trait LockImportRun<Block: BlockT, B: Backend<Block>> {
/// Lock the import lock, and run operations inside.
fn lock_import_and_run<R, Err, F>(&self, f: F) -> Result<R, Err>
where
Expand Down
10 changes: 7 additions & 3 deletions client/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ use futures::prelude::*;
use futures::StreamExt;
use log::{debug, info};
use futures::channel::mpsc;
use sc_client_api::{ClientBackend, BlockchainEvents, CallExecutor, backend::{AuxStore, Backend}, ExecutionStrategy, Finalizer, TransactionFor};
use sc_client_api::{
LockImportRun, BlockchainEvents, CallExecutor,
backend::{AuxStore, Backend}, ExecutionStrategy, Finalizer, TransactionFor,
};
use sp_blockchain::{HeaderBackend, Error as ClientError, HeaderMetadata};
use sc_client::Client;
use parity_scale_codec::{Decode, Encode};
Expand Down Expand Up @@ -259,8 +262,9 @@ impl<Block: BlockT, Client> BlockStatus<Block> for Arc<Client> where

/// A trait that includes all the client functionalities grandpa requires.
/// Ideally this would be a trait alias, we're not there yet.
/// tracking issue https://github.com/rust-lang/rust/issues/41517
pub trait ClientForGrandpa<Block, BE>:
ClientBackend<Block, BE> + Finalizer<Block, BE> + AuxStore
LockImportRun<Block, BE> + Finalizer<Block, BE> + AuxStore
+ HeaderMetadata<Block, Error = sp_blockchain::Error> + HeaderBackend<Block>
+ BlockchainEvents<Block> + ProvideRuntimeApi<Block>
+ BlockImport<Block, Transaction = TransactionFor<BE, Block>, Error = sp_consensus::Error>
Expand All @@ -273,7 +277,7 @@ impl<Block, BE, T> ClientForGrandpa<Block, BE> for T
where
BE: Backend<Block>,
Block: BlockT,
T: ClientBackend<Block, BE> + Finalizer<Block, BE> + AuxStore
T: LockImportRun<Block, BE> + Finalizer<Block, BE> + AuxStore
+ HeaderMetadata<Block, Error = sp_blockchain::Error> + HeaderBackend<Block>
+ BlockchainEvents<Block> + ProvideRuntimeApi<Block>
+ BlockImport<Block, Transaction = TransactionFor<BE, Block>, Error = sp_consensus::Error>,
Expand Down
5 changes: 4 additions & 1 deletion client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
use super::*;
use environment::HasVoted;
use sc_network_test::{Block, Hash, TestNetFactory, BlockImportAdapter, Peer, PeersClient, PassThroughVerifier, PeersFullClient};
use sc_network_test::{
Block, Hash, TestNetFactory, BlockImportAdapter, Peer,
PeersClient, PassThroughVerifier, PeersFullClient,
};
use sc_network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder};
use parking_lot::Mutex;
use futures_timer::Delay;
Expand Down
6 changes: 3 additions & 3 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub use sc_client_api::{
backend::{
self, BlockImportOperation, PrunableStateChangesTrieStorage,
ClientImportOperation, Finalizer, ImportSummary, NewBlockState,
ClientBackend, changes_tries_state_at_block,
LockImportRun, changes_tries_state_at_block,
},
client::{
ImportNotifications, FinalityNotification, FinalityNotifications, BlockImportNotification,
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<B, E, Block, RA> BlockOf for Client<B, E, Block, RA> where
type Type = Block;
}

impl<B, E, Block, RA> ClientBackend<Block, B> for Client<B, E, Block, RA>
impl<B, E, Block, RA> LockImportRun<Block, B> for Client<B, E, Block, RA>
where
B: backend::Backend<Block>,
E: CallExecutor<Block>,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl<B, E, Block, RA> ClientBackend<Block, B> for Client<B, E, Block, RA>
}
}

impl<B, E, Block, RA> ClientBackend<Block, B> for &Client<B, E, Block, RA>
impl<B, E, Block, RA> LockImportRun<Block, B> for &Client<B, E, Block, RA>
where
Block: BlockT,
B: backend::Backend<Block>,
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub use crate::{
client::{
new_with_backend,
new_in_mem,
BlockBody, ImportNotifications, FinalityNotifications, BlockchainEvents, ClientBackend,
BlockBody, ImportNotifications, FinalityNotifications, BlockchainEvents, LockImportRun,
BlockImportNotification, Client, ClientInfo, ExecutionStrategies, FinalityNotification,
LongestChain, BlockOf, ProvideUncles, BadBlocks, ForkBlocks, apply_aux,
},
Expand Down

0 comments on commit 4907e0b

Please sign in to comment.