From 8394920b7335c5b453c1e96bdd5101617b3fce3d Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 16 Jan 2025 16:25:21 +0700 Subject: [PATCH] fix(cardano-blockchain-types): use cat-types Signed-off-by: bkioshn --- .../src/auxdata/metadatum.rs | 2 +- rust/cardano-blockchain-types/src/fork.rs | 2 +- rust/cardano-blockchain-types/src/network.rs | 3 +- rust/cardano-blockchain-types/src/point.rs | 33 ++++++++----------- rust/cardano-blockchain-types/src/slot.rs | 3 +- .../cardano-blockchain-types/src/txn_index.rs | 2 +- .../src/txn_witness.rs | 3 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/rust/cardano-blockchain-types/src/auxdata/metadatum.rs b/rust/cardano-blockchain-types/src/auxdata/metadatum.rs index 4b107d13c2..f85c16082f 100644 --- a/rust/cardano-blockchain-types/src/auxdata/metadatum.rs +++ b/rust/cardano-blockchain-types/src/auxdata/metadatum.rs @@ -2,11 +2,11 @@ use std::sync::Arc; +use catalyst_types::conversion::from_saturating; use dashmap::DashMap; use minicbor::Decode; use super::{metadatum_label::MetadatumLabel, metadatum_value::MetadatumValue}; -use crate::conversion::from_saturating; /// Transaction Metadata /// See: diff --git a/rust/cardano-blockchain-types/src/fork.rs b/rust/cardano-blockchain-types/src/fork.rs index 9679fb576a..6c1f57c4c4 100644 --- a/rust/cardano-blockchain-types/src/fork.rs +++ b/rust/cardano-blockchain-types/src/fork.rs @@ -8,7 +8,7 @@ use std::fmt; -use crate::conversion::from_saturating; +use catalyst_types::conversion::from_saturating; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd)] /// Counter that is incremented every time there is a roll-back in live-chain. diff --git a/rust/cardano-blockchain-types/src/network.rs b/rust/cardano-blockchain-types/src/network.rs index 95b9d47cbf..35b687a383 100644 --- a/rust/cardano-blockchain-types/src/network.rs +++ b/rust/cardano-blockchain-types/src/network.rs @@ -2,6 +2,7 @@ use std::{ffi::OsStr, path::PathBuf}; +use catalyst_types::conversion::from_saturating; use chrono::{DateTime, Utc}; use pallas::{ ledger::traverse::wellknown::GenesisValues, @@ -11,7 +12,7 @@ use pallas::{ // use strum_macros; use tracing::debug; -use crate::{conversion::from_saturating, Slot}; +use crate::Slot; /// Default name of the executable if we can't derive it. pub(crate) const DEFAULT_EXE_NAME: &str = "cardano_chain_follower"; diff --git a/rust/cardano-blockchain-types/src/point.rs b/rust/cardano-blockchain-types/src/point.rs index d2d391459c..9e2de6d964 100644 --- a/rust/cardano-blockchain-types/src/point.rs +++ b/rust/cardano-blockchain-types/src/point.rs @@ -8,9 +8,10 @@ use std::{ fmt::{Debug, Display, Formatter}, }; +use catalyst_types::hashes::Blake2b256Hash; use pallas::crypto::hash::Hash; -use crate::{hashes::Blake2b256Hash, Slot}; +use crate::Slot; /// A specific point in the blockchain. It can be used to /// identify a particular location within the blockchain, such as the tip (the @@ -347,11 +348,9 @@ impl PartialEq> for Point { pallas::network::miniprotocols::Point::Origin => false, } }, - None => { - match self.0 { - pallas::network::miniprotocols::Point::Specific(_, ref hash) => hash.is_empty(), - pallas::network::miniprotocols::Point::Origin => true, - } + None => match self.0 { + pallas::network::miniprotocols::Point::Specific(_, ref hash) => hash.is_empty(), + pallas::network::miniprotocols::Point::Origin => true, }, } } @@ -470,26 +469,22 @@ fn cmp_point( a: &pallas::network::miniprotocols::Point, b: &pallas::network::miniprotocols::Point, ) -> Ordering { match a { - pallas::network::miniprotocols::Point::Origin => { - match b { - pallas::network::miniprotocols::Point::Origin => Ordering::Equal, - pallas::network::miniprotocols::Point::Specific(..) => Ordering::Less, - } + pallas::network::miniprotocols::Point::Origin => match b { + pallas::network::miniprotocols::Point::Origin => Ordering::Equal, + pallas::network::miniprotocols::Point::Specific(..) => Ordering::Less, }, - pallas::network::miniprotocols::Point::Specific(slot, _) => { - match b { - pallas::network::miniprotocols::Point::Origin => Ordering::Greater, - pallas::network::miniprotocols::Point::Specific(other_slot, _) => { - slot.cmp(other_slot) - }, - } + pallas::network::miniprotocols::Point::Specific(slot, _) => match b { + pallas::network::miniprotocols::Point::Origin => Ordering::Greater, + pallas::network::miniprotocols::Point::Specific(other_slot, _) => slot.cmp(other_slot), }, } } #[cfg(test)] mod tests { - use crate::{hashes::Blake2bHash, point::*}; + use catalyst_types::hashes::Blake2bHash; + + use crate::point::*; #[test] fn test_cmp_hash_simple() { diff --git a/rust/cardano-blockchain-types/src/slot.rs b/rust/cardano-blockchain-types/src/slot.rs index 80d0512f2a..8cb565d836 100644 --- a/rust/cardano-blockchain-types/src/slot.rs +++ b/rust/cardano-blockchain-types/src/slot.rs @@ -5,11 +5,10 @@ use std::{ ops::{MulAssign, Sub}, }; +use catalyst_types::conversion::from_saturating; use num_bigint::{BigInt, Sign}; use serde::Serialize; -use crate::conversion::from_saturating; - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default, Serialize)] /// Slot on the blockchain, typically one slot equals one second. However chain diff --git a/rust/cardano-blockchain-types/src/txn_index.rs b/rust/cardano-blockchain-types/src/txn_index.rs index 716117c4b7..1d238af454 100644 --- a/rust/cardano-blockchain-types/src/txn_index.rs +++ b/rust/cardano-blockchain-types/src/txn_index.rs @@ -1,5 +1,5 @@ //! Transaction Index -use crate::conversion::from_saturating; +use catalyst_types::conversion::from_saturating; /// Transaction index within a block /// See: diff --git a/rust/cardano-blockchain-types/src/txn_witness.rs b/rust/cardano-blockchain-types/src/txn_witness.rs index 5d7a7977f9..60fd6707cb 100644 --- a/rust/cardano-blockchain-types/src/txn_witness.rs +++ b/rust/cardano-blockchain-types/src/txn_witness.rs @@ -1,11 +1,12 @@ //! Transaction Witness use std::fmt::{Display, Formatter}; +use catalyst_types::{conversion::vkey_from_bytes, hashes::Blake2b224Hash}; use dashmap::{DashMap, DashSet}; use ed25519_dalek::VerifyingKey; use pallas::ledger::traverse::MultiEraTx; -use crate::{conversion::vkey_from_bytes, hashes::Blake2b224Hash, TxnIndex}; +use crate::TxnIndex; /// Hash of a witness verifying public key pub type VKeyHash = Blake2b224Hash;