Permalink
Browse files

Avoid get_header()

  • Loading branch information...
edolstra committed Jan 11, 2019
1 parent 653ae6b commit 0ffa0f8a18724fbd88172de6c50171474434c2d0
Showing with 9 additions and 30 deletions.
  1. +7 −13 cardano/src/block/block.rs
  2. +1 −3 cardano/src/block/date.rs
  3. +0 −3 cardano/src/block/types.rs
  4. +0 −2 cardano/src/lib.rs
  5. +1 −9 cardano/src/tx.rs
@@ -80,7 +80,7 @@ pub enum BlockHeader {
MainBlockHeader(normal::BlockHeader),
}

impl core::property::Header for BlockHeader {}
impl chain_core::property::Header for BlockHeader {}

/// BlockHeaders is a vector of block headers, as produced by
/// MsgBlocks.
@@ -214,7 +214,10 @@ impl chain_core::property::Block for Block {
}

fn parent_id(&self) -> Self::Id {
self.get_header().get_previous_header()
match self {
Block::MainBlock(ref block) => block.header.previous_header.clone(),
Block::BoundaryBlock(ref block) => block.header.previous_header.clone(),
}
}

fn date(&self) -> Self::Date {
@@ -229,16 +232,7 @@ impl chain_core::property::Block for Block {
}
}

impl core::property::HasTransaction<TxAux> for Block {
fn transactions<'a>(&'a self) -> std::slice::Iter<'a, TxAux> {
match self {
&Block::BoundaryBlock(_) => [].iter(),
&Block::MainBlock(ref blk) => blk.body.tx.iter(),
}
}
}

impl core::property::Serialize for Block {
impl chain_core::property::Serialize for Block {
type Error = cbor_event::Error;

fn serialize<W: std::io::Write>(&self, mut writer: W) -> Result<(), Self::Error> {
@@ -248,7 +242,7 @@ impl core::property::Serialize for Block {
}
}

impl core::property::Deserialize for Block {
impl chain_core::property::Deserialize for Block {
type Error = cbor_event::Error;

fn deserialize<R: std::io::BufRead>(reader: R) -> Result<Self, Self::Error> {
@@ -19,8 +19,6 @@ pub enum BlockDate {
Normal(EpochSlotId),
}

impl property::BlockDate for BlockDate {}

impl ::std::ops::Sub<BlockDate> for BlockDate {
type Output = usize;
fn sub(self, rhs: Self) -> Self::Output {
@@ -127,7 +125,7 @@ impl str::FromStr for BlockDate {
}
}

impl chain_core::property::BlockDate for BlockDate {
impl property::BlockDate for BlockDate {
fn serialize(&self) -> u64 {
match self {
BlockDate::Boundary(epoch) => epoch << 16,
@@ -1,6 +1,5 @@
use super::normal::SscPayload;
use cbor_event::{self, de::Deserializer, se::Serializer};
use chain_core::property;
use hash::Blake2b256;
use util::try_from_slice::TryFromSlice;

@@ -49,8 +48,6 @@ impl HeaderHash {
}
}

impl property::BlockId for HeaderHash {}

impl fmt::Display for HeaderHash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
@@ -15,8 +15,6 @@
//!
#![cfg_attr(feature = "with-bench", feature(test))]

extern crate chain_core;

#[cfg(feature = "generic-serialization")]
#[macro_use]
extern crate serde_derive;
@@ -22,16 +22,8 @@ use crate::{
};

use cbor_event::{self, de::Deserializer, se::Serializer};
use config::ProtocolMagic;
use merkle;
use redeem;
use tags::SigningTag;

use address::{AddrType, Attributes, ExtendedAddr, SpendingData};
use coin::{self, Coin};
use hdwallet::{Signature, XPrv, XPub, SIGNATURE_SIZE, XPUB_SIZE};

use chain_core;
use chain_core::property;

// Transaction IDs are either a hash of the CBOR serialisation of a
// given Tx, or a hash of a redeem address.

0 comments on commit 0ffa0f8

Please sign in to comment.