fixed bugs introduced during refactor
This commit is contained in:
parent
0811e876c0
commit
14f764ebcf
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue