diff --git a/db/src/indexed_block.rs b/db/src/indexed_block.rs index b11061c7..5f4af5b7 100644 --- a/db/src/indexed_block.rs +++ b/db/src/indexed_block.rs @@ -1,5 +1,5 @@ use primitives::hash::H256; -use chain::{Block, BlockHeader, OutPoint, TransactionOutput, merkle_root}; +use chain::{Block, OutPoint, TransactionOutput, merkle_root}; use serialization::Serializable; use indexed_header::IndexedBlockHeader; use indexed_transaction::IndexedTransaction; @@ -18,7 +18,7 @@ impl PreviousTransactionOutputProvider for IndexedBlock { } fn is_spent(&self, _prevout: &OutPoint) -> bool { - unimplemented!(); + false } } @@ -45,10 +45,6 @@ impl IndexedBlock { &self.header.hash } - pub fn header(&self) -> &BlockHeader { - &self.header.raw - } - pub fn to_raw_block(self) -> Block { Block::new(self.header.raw, self.transactions.into_iter().map(|tx| tx.raw).collect()) } diff --git a/db/src/storage.rs b/db/src/storage.rs index 0032a1ff..434eca78 100644 --- a/db/src/storage.rs +++ b/db/src/storage.rs @@ -190,7 +190,7 @@ impl Storage { ); } - for tx in accepted_txs { + for tx in accepted_txs.iter().skip(1) { context.meta.insert( tx.hash.clone(), TransactionMeta::new(number, tx.raw.outputs.len()) diff --git a/sync/src/blocks_writer.rs b/sync/src/blocks_writer.rs index a3c7985e..489fcdba 100644 --- a/sync/src/blocks_writer.rs +++ b/sync/src/blocks_writer.rs @@ -48,7 +48,7 @@ impl BlocksWriter { return Ok(()); } // verify && insert only if parent block is already in the storage - if !self.storage.contains_block(db::BlockRef::Hash(indexed_block.header().previous_header_hash.clone())) { + if !self.storage.contains_block(db::BlockRef::Hash(indexed_block.header.raw.previous_header_hash.clone())) { self.orphaned_blocks_pool.insert_orphaned_block(indexed_block.hash().clone(), indexed_block); // we can't hold many orphaned blocks in memory during import if self.orphaned_blocks_pool.len() > MAX_ORPHANED_BLOCKS { diff --git a/sync/src/orphan_blocks_pool.rs b/sync/src/orphan_blocks_pool.rs index 702a539b..4e2e3dab 100644 --- a/sync/src/orphan_blocks_pool.rs +++ b/sync/src/orphan_blocks_pool.rs @@ -42,7 +42,7 @@ impl OrphanBlocksPool { /// Insert orphaned block, for which we have already requested its parent block pub fn insert_orphaned_block(&mut self, hash: H256, block: IndexedBlock) { self.orphaned_blocks - .entry(block.header().previous_header_hash.clone()) + .entry(block.header.raw.previous_header_hash.clone()) .or_insert_with(HashMap::new) .insert(hash, block); } diff --git a/sync/src/synchronization_chain.rs b/sync/src/synchronization_chain.rs index 2c7ccc03..b40e51ae 100644 --- a/sync/src/synchronization_chain.rs +++ b/sync/src/synchronization_chain.rs @@ -352,7 +352,7 @@ impl Chain { /// Insert new best block to storage pub fn insert_best_block(&mut self, hash: H256, block: &IndexedBlock) -> Result { - let is_appending_to_main_branch = self.best_storage_block.hash == block.header().previous_header_hash; + let is_appending_to_main_branch = self.best_storage_block.hash == block.header.raw.previous_header_hash; // insert to storage let storage_insertion = try!(self.storage.insert_indexed_block(&block)); diff --git a/sync/src/synchronization_client.rs b/sync/src/synchronization_client.rs index 954970f9..66811efe 100644 --- a/sync/src/synchronization_client.rs +++ b/sync/src/synchronization_client.rs @@ -1466,7 +1466,7 @@ impl SynchronizationClientCore where T: TaskExecutor { } // check parent block state - let parent_block_state = chain.block_state(&block.header().previous_header_hash); + let parent_block_state = chain.block_state(&block.header.raw.previous_header_hash); match parent_block_state { BlockState::Unknown | BlockState::DeadEnd => { if parent_block_state == BlockState::DeadEnd { @@ -1510,7 +1510,7 @@ impl SynchronizationClientCore where T: TaskExecutor { let blocks_hashes_to_forget: Vec<_> = blocks_to_verify.iter().map(|t| t.0.clone()).collect(); chain.forget_blocks_leave_header(&blocks_hashes_to_forget); // remember that we are verifying these blocks - let blocks_headers_to_verify: Vec<_> = blocks_to_verify.iter().map(|&(ref h, ref b)| (h.clone(), b.header().clone())).collect(); + let blocks_headers_to_verify: Vec<_> = blocks_to_verify.iter().map(|&(ref h, ref b)| (h.clone(), b.header.raw.clone())).collect(); chain.verify_blocks(blocks_headers_to_verify); // remember that we are verifying block from this peer for verifying_block_hash in blocks_to_verify.iter().map(|&(ref h, _)| h.clone()) {