Skip to content
Permalink
Browse files

remove some Eq

  • Loading branch information...
vincenthz committed Mar 14, 2019
1 parent 3940bc4 commit f06c98468a17a332b2a8642528e7e588a11f94ef
@@ -131,7 +131,7 @@ impl Header {
/// function to compute the Header Hash as per the spec. It is the hash
/// of the serialized header (except the first 2bytes: the size)
#[inline]
fn hash(&self) -> HeaderHash {
pub fn hash(&self) -> HeaderHash {
// TODO: this is not the optimal way to compute the crypto graphic hash
use chain_core::property::Serialize;
let bytes = self.serialize_as_vec().unwrap();
@@ -1,6 +1,6 @@
use chain_addr::Address;
use chain_core::{packer, property};
use chain_crypto::Ed25519Extended;
use chain_addr::Address;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
use std::mem::size_of;
@@ -12,7 +12,7 @@ use crate::{
transaction::SignedTransaction,
};

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
pub enum Message {
Transaction(SignedTransaction<Address>),

@@ -22,16 +22,29 @@ pub use crate::date::{BlockDate, BlockDateParseError};
/// `Block` is an element of the blockchain it contains multiple
/// transaction and a reference to the parent block. Alongside
/// with the position of that block in the chain.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
pub struct Block {
pub header: Header,

pub contents: BlockContents,
}

#[derive(Debug, Clone, PartialEq, Eq)]
impl PartialEq for Block {
fn eq(&self, rhs: &Self) -> bool {
self.header.hash() == rhs.header.hash()
}
}
impl Eq for Block {}

#[derive(Debug, Clone)]
pub struct BlockContents(Vec<Message>);

impl PartialEq for BlockContents {
fn eq(&self, rhs: &Self) -> bool {
self.compute_hash_size() == rhs.compute_hash_size()
}
}
impl Eq for BlockContents {}

impl BlockContents {
#[inline]
pub fn new(messages: Vec<Message>) -> Self {
@@ -2,7 +2,7 @@
use crate::transaction::*;
use chain_addr::Address;

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone)]
pub enum Error {
/// If the Ledger could not find the given input in the UTxO list it will
/// report this error.

0 comments on commit f06c984

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.