fix warnings

This commit is contained in:
NikVolf 2016-11-28 16:40:22 +03:00
parent 0320a7c6ed
commit cfaa6fadbf
7 changed files with 12 additions and 36 deletions

View File

@ -2,7 +2,6 @@ use std::collections::{HashMap, HashSet, VecDeque};
use std::collections::hash_map::Entry;
use linked_hash_map::LinkedHashMap;
use time;
use chain::Block;
use primitives::hash::H256;
use db::IndexedBlock;

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use std::collections::VecDeque;
use linked_hash_map::LinkedHashMap;
use parking_lot::RwLock;
use chain::{Block, BlockHeader, Transaction};
use chain::{BlockHeader, Transaction};
use db::{self, IndexedBlock};
use best_headers_chain::{BestHeadersChain, Information as BestHeadersInformation};
use primitives::bytes::Bytes;

View File

@ -8,7 +8,7 @@ use futures::stream::Stream;
use tokio_core::reactor::{Handle, Interval};
use futures_cpupool::CpuPool;
use db::{self, IndexedBlock};
use chain::{Block, BlockHeader, Transaction};
use chain::{BlockHeader, Transaction};
use message::types;
use message::common::{InventoryVector, InventoryType};
use primitives::hash::H256;

View File

@ -2,7 +2,7 @@ use std::thread;
use std::sync::Arc;
use std::sync::mpsc::{channel, Sender, Receiver};
use parking_lot::Mutex;
use chain::{Block, Transaction};
use chain::Transaction;
use network::{Magic, ConsensusParams};
use primitives::hash::H256;
use verification::{ChainVerifier, Verify as VerificationVerify};
@ -152,7 +152,7 @@ pub mod tests {
use std::sync::Arc;
use std::collections::HashMap;
use parking_lot::Mutex;
use chain::{Block, Transaction};
use chain::Transaction;
use synchronization_client::SynchronizationClientCore;
use synchronization_executor::tests::DummyTaskExecutor;
use primitives::hash::H256;

View File

@ -1,12 +1,11 @@
//! Bitcoin chain verifier
use std::collections::BTreeSet;
use db::{self, BlockRef, BlockLocation, IndexedBlock};
use db::{self, BlockRef, BlockLocation};
use network::Magic;
use script::Script;
use super::{Verify, VerificationResult, Chain, Error, TransactionError, ContinueVerify};
use {chain, utils};
use primitives::H256;
const BLOCK_MAX_FUTURE: i64 = 2 * 60 * 60; // 2 hours
const COINBASE_MATURITY: u32 = 100; // 2 hours
@ -61,7 +60,7 @@ impl ChainVerifier {
fn previous_transaction_output(&self, block: &db::IndexedBlock, prevout: &chain::OutPoint) -> Option<chain::TransactionOutput> {
self.store.transaction(&prevout.hash)
.as_ref()
.or_else(|| block.transactions().find(|&(hash, tx)| hash == &prevout.hash).and_then(|(hash, tx)| Some(tx)))
.or_else(|| block.transactions().find(|&(hash, _)| hash == &prevout.hash).and_then(|(_, tx)| Some(tx)))
.and_then(|tx| tx.outputs.iter().nth(prevout.index as usize).cloned())
}
@ -130,7 +129,7 @@ impl ChainVerifier {
.total_spends();
// bip30
for (tx_index, (tx_hash, tx)) in block.transactions().enumerate() {
for (tx_index, (tx_hash, _)) in block.transactions().enumerate() {
if let Some(meta) = self.store.transaction_meta(tx_hash) {
if !meta.is_fully_spent() && !consensus_params.is_bip30_exception(&block_hash, at_height) {
return Err(Error::Transaction(tx_index, TransactionError::UnspentTransactionWithTheSameHash));
@ -139,7 +138,7 @@ impl ChainVerifier {
}
let mut total_unspent = 0u64;
for (tx_index, (tx_hash, tx)) in block.transactions().enumerate().skip(1) {
for (tx_index, (_, tx)) in block.transactions().enumerate().skip(1) {
let mut total_claimed: u64 = 0;
for input in &tx.inputs {
// Coinbase maturity check
@ -178,7 +177,6 @@ impl ChainVerifier {
fn verify_transaction(&self,
block: &db::IndexedBlock,
hash: &H256,
transaction: &chain::Transaction,
sequence: usize,
) -> Result<(), TransactionError> {
@ -283,8 +281,8 @@ impl ChainVerifier {
return Err(Error::CoinbaseSignatureLength(coinbase_script_len));
}
for (idx, (tx_hash, transaction)) in block.transactions().enumerate() {
try!(self.verify_transaction(block, tx_hash, transaction, idx).map_err(|e| Error::Transaction(idx, e)))
for (idx, (_, transaction)) in block.transactions().enumerate() {
try!(self.verify_transaction(block, transaction, idx).map_err(|e| Error::Transaction(idx, e)))
}
// todo: pre-process projected block number once verification is parallel!
@ -368,8 +366,8 @@ impl ContinueVerify for ChainVerifier {
fn continue_verify(&self, block: &db::IndexedBlock, state: usize) -> VerificationResult {
// verify transactions (except coinbase)
for (idx, (tx_hash, transaction)) in block.transactions().enumerate().skip(state - 1) {
try!(self.verify_transaction(block, tx_hash, transaction, idx).map_err(|e| Error::Transaction(idx, e)));
for (idx, (_, transaction)) in block.transactions().enumerate().skip(state - 1) {
try!(self.verify_transaction(block, transaction, idx).map_err(|e| Error::Transaction(idx, e)));
}
let _parent = match self.store.block(BlockRef::Hash(block.header().previous_header_hash.clone())) {

View File

@ -22,7 +22,6 @@ extern crate test_data;
mod chain_verifier;
mod compact;
mod utils;
mod lookup;
pub use primitives::{uint, hash};

View File

@ -1,20 +0,0 @@
use db;
use chain;
use primitives::H256;
use std::collections::HashMap;
struct BlockTransactionLookup<'a, 'b> {
store: &'a db::Store,
block: &'b db::IndexedBlock,
cache: HashMap<H256, chain::Transaction>,
}
impl<'a, 'b> BlockTransactionLookup<'a, 'b> {
fn new(store: &'a db::Store, block: &'b db::IndexedBlock) -> BlockTransactionLookup<'a, 'b> {
BlockTransactionLookup { store: store, block: block, cache: HashMap::new() }
}
fn find(&mut self, hash: &H256) -> Option<(&H256, &chain::Transaction)> {
None
}
}