fixed bugs introduced during refactor

This commit is contained in:
debris 2016-12-09 18:32:28 +01:00
parent 0811e876c0
commit 14f764ebcf
2 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
use primitives::hash::H256;
use chain::{Block, OutPoint, TransactionOutput, merkle_root};
use serialization::Serializable;
use serialization::{Serializable, CompactInteger};
use indexed_header::IndexedBlockHeader;
use indexed_transaction::IndexedTransaction;
use PreviousTransactionOutputProvider;
@ -50,8 +50,10 @@ impl IndexedBlock {
}
pub fn size(&self) -> usize {
let header_size = self.header.raw.serialized_size();
let txs_len_size = CompactInteger::from(self.transactions.len()).serialized_size();
let txs_size = self.transactions.iter().map(|tx| tx.raw.serialized_size()).sum::<usize>();
self.header.raw.serialized_size() + txs_size
header_size + txs_len_size + txs_size
}
pub fn merkle_root(&self) -> H256 {

View File

@ -37,7 +37,8 @@ impl<'a> PreviousTransactionOutputProvider for &'a [IndexedTransaction] {
fn previous_transaction_output(&self, prevout: &OutPoint) -> Option<TransactionOutput> {
self.iter()
.find(|tx| tx.hash == prevout.hash)
.map(|tx| tx.raw.outputs[prevout.index as usize].clone())
.and_then(|tx| tx.raw.outputs.get(prevout.index as usize))
.cloned()
}
fn is_spent(&self, _prevout: &OutPoint) -> bool {