Refactor to use only chain info (#4516)

This commit is contained in:
Nikolay Volf
2020-01-02 14:46:07 +03:00
committed by Bastian Köcher
parent 8ecc450fd9
commit 6d06a19f41
30 changed files with 178 additions and 175 deletions
+8 -8
View File
@@ -28,10 +28,10 @@ use libp2p::build_multiaddr;
use log::trace;
use sc_network::FinalityProofProvider;
use sp_blockchain::{
Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId},
Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId}, Info as BlockchainInfo,
};
use sc_client_api::{
ClientInfo, BlockchainEvents, BlockImportNotification,
BlockchainEvents, BlockImportNotification,
FinalityNotifications, ImportNotifications,
FinalityNotification,
backend::{AuxStore, Backend, Finalizer}
@@ -161,10 +161,10 @@ impl PeersClient {
}
}
pub fn info(&self) -> ClientInfo<Block> {
pub fn info(&self) -> BlockchainInfo<Block> {
match *self {
PeersClient::Full(ref client, ref _backend) => client.info(),
PeersClient::Light(ref client, ref _backend) => client.info(),
PeersClient::Full(ref client, ref _backend) => client.chain_info(),
PeersClient::Light(ref client, ref _backend) => client.chain_info(),
}
}
@@ -270,7 +270,7 @@ impl<D, S: NetworkSpecialization<Block>> Peer<D, S> {
pub fn generate_blocks<F>(&mut self, count: usize, origin: BlockOrigin, edit_block: F) -> H256
where F: FnMut(BlockBuilder<Block, PeersFullClient>) -> Block
{
let best_hash = self.client.info().chain.best_hash;
let best_hash = self.client.info().best_hash;
self.generate_blocks_at(BlockId::Hash(best_hash), count, origin, edit_block)
}
@@ -320,7 +320,7 @@ impl<D, S: NetworkSpecialization<Block>> Peer<D, S> {
/// Push blocks to the peer (simplified: with or without a TX)
pub fn push_blocks(&mut self, count: usize, with_tx: bool) -> H256 {
let best_hash = self.client.info().chain.best_hash;
let best_hash = self.client.info().best_hash;
self.push_blocks_at(BlockId::Hash(best_hash), count, with_tx)
}
@@ -689,7 +689,7 @@ pub trait TestNetFactory: Sized {
if peer.is_major_syncing() || peer.network.num_queued_blocks() != 0 {
return Async::NotReady
}
match (highest, peer.client.info().chain.best_hash) {
match (highest, peer.client.info().best_hash) {
(None, b) => highest = Some(b),
(Some(ref a), ref b) if a == b => {},
(Some(_), _) => return Async::NotReady,