diff --git a/chain/src/block.rs b/chain/src/block.rs index 67e24379..38169bd3 100644 --- a/chain/src/block.rs +++ b/chain/src/block.rs @@ -41,9 +41,7 @@ impl From<&'static str> for Block { } impl RepresentH256 for Block { - fn hash(&self) -> H256 { - self.block_header.hash() - } + fn h256(&self) -> H256 { self.hash() } } impl Block { @@ -68,13 +66,16 @@ impl Block { pub fn drain(self) -> (BlockHeader, Vec) { (self.block_header, self.transactions) } + + pub fn hash(&self) -> H256 { + self.block_header.hash() + } } #[cfg(test)] mod tests { use hash::H256; use super::Block; - use super::super::RepresentH256; // Block 80000 // https://blockchain.info/rawblock/000000000043a8c0fd1d6f726790caa2a406010d19efd2780db27bdbbd93baf6 diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 43b31b33..d0bd9799 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -10,7 +10,7 @@ mod merkle_root; mod transaction; pub trait RepresentH256 { - fn hash(&self) -> primitives::hash::H256; + fn h256(&self) -> primitives::hash::H256; } pub use rustc_serialize::hex; diff --git a/db/src/storage.rs b/db/src/storage.rs index e9ce0be1..bf749d8f 100644 --- a/db/src/storage.rs +++ b/db/src/storage.rs @@ -8,7 +8,7 @@ use primitives::hash::H256; use primitives::bytes::Bytes; use super::{BlockRef, BestBlock, BlockLocation}; use serialization::{serialize, deserialize}; -use chain::{self, RepresentH256}; +use chain; use parking_lot::RwLock; use transaction_meta::TransactionMeta; @@ -610,7 +610,7 @@ mod tests { use super::{Storage, Store}; use devtools::RandomTempPath; - use chain::{Block, RepresentH256}; + use chain::Block; use super::super::{BlockRef, BlockLocation}; use test_data; diff --git a/db/src/test_storage.rs b/db/src/test_storage.rs index 4974a761..2c2bd514 100644 --- a/db/src/test_storage.rs +++ b/db/src/test_storage.rs @@ -4,7 +4,7 @@ use super::{ BlockRef, Store, Error, BestBlock, BlockLocation, BlockInsertedChain, BlockProvider, BlockStapler, TransactionMetaProvider, TransactionProvider, }; -use chain::{self, Block, RepresentH256}; +use chain::{self, Block}; use primitives::hash::H256; use serialization; use chain::bytes::Bytes; diff --git a/sync/src/orphan_blocks_pool.rs b/sync/src/orphan_blocks_pool.rs index ce8b3f7e..ef82f2d2 100644 --- a/sync/src/orphan_blocks_pool.rs +++ b/sync/src/orphan_blocks_pool.rs @@ -103,7 +103,7 @@ impl OrphanBlocksPool { } orphans.is_empty() }; - + if remove_entry { orphan_entry.remove_entry(); } @@ -124,7 +124,6 @@ mod tests { use std::collections::HashSet; use test_data; use primitives::hash::H256; - use chain::RepresentH256; use super::OrphanBlocksPool; #[test] diff --git a/test-data/src/block.rs b/test-data/src/block.rs index e7fa5d64..235e2abd 100644 --- a/test-data/src/block.rs +++ b/test-data/src/block.rs @@ -1,7 +1,7 @@ //! Block builder use super::genesis; -use chain::{self, RepresentH256}; +use chain; use primitives::hash::H256; use primitives::bytes::Bytes; use invoke::{Invoke, Identity}; diff --git a/verification/src/chain_verifier.rs b/verification/src/chain_verifier.rs index 32e891d7..280ff795 100644 --- a/verification/src/chain_verifier.rs +++ b/verification/src/chain_verifier.rs @@ -1,7 +1,7 @@ //! Bitcoin chain verifier use db::{self, BlockRef, BlockLocation}; -use chain::{self, RepresentH256}; +use chain; use super::{Verify, VerificationResult, Chain, Error, TransactionError, ContinueVerify}; use utils; @@ -277,7 +277,6 @@ mod tests { use test_data; use std::sync::Arc; use devtools::RandomTempPath; - use chain::RepresentH256; use script; #[test] diff --git a/verification/src/queue.rs b/verification/src/queue.rs index 00af11cd..84abfd02 100644 --- a/verification/src/queue.rs +++ b/verification/src/queue.rs @@ -1,6 +1,6 @@ //! Blocks verification queue -use chain::{Block, RepresentH256}; +use chain::Block; use primitives::hash::H256; use super::{Chain, ContinueVerify, BlockStatus, Error as VerificationError, TransactionError}; use linked_hash_map::LinkedHashMap; @@ -204,7 +204,7 @@ impl Queue { mod tests { use super::Queue; use super::super::{BlockStatus, VerificationResult, Verify, ContinueVerify, Chain, Error as VerificationError, TransactionError}; - use chain::{Block, RepresentH256}; + use chain::Block; use primitives::hash::H256; use test_data; use std::collections::HashMap;