replaced client block_details with block_total_difficulty

This commit is contained in:
debris
2016-01-27 14:43:43 +01:00
parent 1402fd5c4c
commit 7ffe9344ed
2 changed files with 14 additions and 8 deletions

View File

@@ -13,7 +13,6 @@ use service::NetSyncMessage;
use env_info::LastHashes;
use verification::*;
use block::*;
use extras::BlockDetails;
/// General block status
#[derive(Debug)]
@@ -67,8 +66,8 @@ pub trait BlockChainClient : Sync + Send {
/// Get block status by block header hash.
fn block_status(&self, hash: &H256) -> BlockStatus;
/// Get familial details concerning a block.
fn block_details(&self, hash: &H256) -> Option<BlockDetails>;
/// Get block total difficulty.
fn block_total_difficulty(&self, hash: &H256) -> Option<U256>;
/// Get raw block header data by block number.
fn block_header_at(&self, n: BlockNumber) -> Option<Bytes>;
@@ -83,6 +82,9 @@ pub trait BlockChainClient : Sync + Send {
/// Get block status by block number.
fn block_status_at(&self, n: BlockNumber) -> BlockStatus;
/// Get block total difficulty.
fn block_total_difficulty_at(&self, n: BlockNumber) -> Option<U256>;
/// Get a tree route between `from` and `to`.
/// See `BlockChain::tree_route`.
fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute>;
@@ -321,8 +323,8 @@ impl BlockChainClient for Client {
if self.chain.read().unwrap().is_known(&hash) { BlockStatus::InChain } else { BlockStatus::Unknown }
}
fn block_details(&self, hash: &H256) -> Option<BlockDetails> {
self.chain.read().unwrap().block_details(hash)
fn block_total_difficulty(&self, hash: &H256) -> Option<U256> {
self.chain.read().unwrap().block_details(hash).map(|d| d.total_difficulty)
}
fn block_header_at(&self, n: BlockNumber) -> Option<Bytes> {
@@ -344,6 +346,10 @@ impl BlockChainClient for Client {
}
}
fn block_total_difficulty_at(&self, n: BlockNumber) -> Option<U256> {
self.chain.read().unwrap().block_hash(n).and_then(|h| self.block_total_difficulty(&h))
}
fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute> {
self.chain.read().unwrap().tree_route(from.clone(), to.clone())
}