Consolidate validation in Block and Transaction (#1354)

* Consolidate validation in Block and Transaction

Introduce TransactionBody which is included into block and tx.
Fixes #1333
This commit is contained in:
hashmap
2018-08-15 23:14:48 +02:00
committed by GitHub
parent 37fa413329
commit 99a66c1960
20 changed files with 570 additions and 476 deletions
+9 -6
View File
@@ -292,7 +292,8 @@ impl OutputPrintable {
}
pub fn range_proof(&self) -> Result<pedersen::RangeProof, ser::Error> {
let proof_str = self.proof
let proof_str = self
.proof
.clone()
.ok_or_else(|| ser::Error::HexError(format!("output range_proof missing")))
.unwrap();
@@ -531,12 +532,12 @@ impl BlockPrintable {
include_proof: bool,
) -> BlockPrintable {
let inputs = block
.inputs
.inputs()
.iter()
.map(|x| util::to_hex(x.commitment().0.to_vec()))
.collect();
let outputs = block
.outputs
.outputs()
.iter()
.map(|output| {
OutputPrintable::from_output(
@@ -548,7 +549,7 @@ impl BlockPrintable {
})
.collect();
let kernels = block
.kernels
.kernels()
.iter()
.map(|kernel| TxKernelPrintable::from_txkernel(kernel))
.collect();
@@ -581,11 +582,13 @@ impl CompactBlockPrintable {
chain: Arc<chain::Chain>,
) -> CompactBlockPrintable {
let block = chain.get_block(&cb.hash()).unwrap();
let out_full = cb.out_full
let out_full = cb
.out_full
.iter()
.map(|x| OutputPrintable::from_output(x, chain.clone(), Some(&block.header), false))
.collect();
let kern_full = cb.kern_full
let kern_full = cb
.kern_full
.iter()
.map(|x| TxKernelPrintable::from_txkernel(x))
.collect();