Skip to content

Commit

Permalink
fix(cardano-blockchain-types): use cat-types
Browse files Browse the repository at this point in the history
Signed-off-by: bkioshn <[email protected]>
  • Loading branch information
bkioshn committed Jan 16, 2025
1 parent 37c02db commit 8394920
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/auxdata/metadatum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/IntersectMBO/cardano-ledger/blob/78b32d585fd4a0340fb2b184959fb0d46f32c8d2/eras/conway/impl/cddl-files/conway.cddl#L519>
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion rust/cardano-blockchain-types/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";
Expand Down
33 changes: 14 additions & 19 deletions rust/cardano-blockchain-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -347,11 +348,9 @@ impl PartialEq<Option<Blake2b256Hash>> 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,
},
}
}
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions rust/cardano-blockchain-types/src/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rust/cardano-blockchain-types/src/txn_index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Transaction Index
use crate::conversion::from_saturating;
use catalyst_types::conversion::from_saturating;

/// Transaction index within a block
/// See: <https://github.com/IntersectMBO/cardano-ledger/blob/78b32d585fd4a0340fb2b184959fb0d46f32c8d2/eras/conway/impl/cddl-files/conway.cddl#L20C1-L20C33>
Expand Down
3 changes: 2 additions & 1 deletion rust/cardano-blockchain-types/src/txn_witness.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 8394920

Please sign in to comment.