Skip to content

Commit fe12099

Browse files
committed
feat: add new ChainPoint entity
That represents a point on the Cardano chain.
1 parent b9e810f commit fe12099

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

mithril-common/src/entities/block_range.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ use std::{
88

99
use crate::{
1010
crypto_helper::{MKMapKey, MKTreeNode},
11+
entities::BlockNumber,
1112
StdResult,
1213
};
1314

14-
/// BlockNumber is the block number of a Cardano transaction.
15-
pub type BlockNumber = u64;
16-
1715
/// BlockRangeLength is the length of a block range.
1816
pub type BlockRangeLength = u64;
1917

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// [Cardano Slot number](https://docs.cardano.org/learn/cardano-node/#slotsandepochs)
4+
pub type SlotNumber = u64;
5+
6+
/// BlockNumber is the block number of a Cardano transaction.
7+
pub type BlockNumber = u64;
8+
9+
/// Hash of a Cardano Block
10+
pub type BlockHash = String;
11+
12+
///The Cardano chain point which is used to identify a specific point in the Cardano chain.
13+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
14+
pub struct ChainPoint {
15+
/// The slot number
16+
pub slot_number: SlotNumber,
17+
18+
/// The block number
19+
pub block_number: BlockNumber,
20+
21+
/// The hex encoded block hash
22+
pub block_hash: BlockHash,
23+
}

mithril-common/src/entities/cardano_transaction.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
use crate::crypto_helper::MKTreeNode;
2-
3-
use super::{BlockNumber, ImmutableFileNumber};
1+
use crate::{
2+
crypto_helper::MKTreeNode,
3+
entities::{BlockHash, BlockNumber, ImmutableFileNumber, SlotNumber},
4+
};
45

56
/// TransactionHash is the unique identifier of a cardano transaction.
67
pub type TransactionHash = String;
7-
/// Hash of a Cardano Block
8-
pub type BlockHash = String;
9-
/// [Cardano Slot number](https://docs.cardano.org/learn/cardano-node/#slotsandepochs)
10-
pub type SlotNumber = u64;
118

129
#[derive(Debug, PartialEq, Clone)]
1310
/// Cardano transaction representation

mithril-common/src/entities/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! The entities used by, and exchanged between, the aggregator, signers and client.
22
33
mod block_range;
4+
mod cardano_chain_point;
45
mod cardano_db_beacon;
56
mod cardano_network;
67
mod cardano_transaction;
@@ -23,10 +24,11 @@ mod snapshot;
2324
mod time_point;
2425
mod type_alias;
2526

26-
pub use block_range::{BlockNumber, BlockRange, BlockRangeLength};
27+
pub use block_range::{BlockRange, BlockRangeLength};
28+
pub use cardano_chain_point::{BlockHash, BlockNumber, ChainPoint, SlotNumber};
2729
pub use cardano_db_beacon::CardanoDbBeacon;
2830
pub use cardano_network::CardanoNetwork;
29-
pub use cardano_transaction::{BlockHash, CardanoTransaction, SlotNumber, TransactionHash};
31+
pub use cardano_transaction::{CardanoTransaction, TransactionHash};
3032
pub use cardano_transactions_set_proof::CardanoTransactionsSetProof;
3133
pub use cardano_transactions_snapshot::CardanoTransactionsSnapshot;
3234
pub use certificate::{Certificate, CertificateSignature};

0 commit comments

Comments
 (0)