Skip to content

Commit 1cd900e

Browse files
committed
refactor: rename CardanoDatabase to CardanoDatabaseSnapshot and documentation enhancements
1 parent 6b27c8b commit 1cd900e

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

mithril-aggregator/src/artifact_builder/cardano_database.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use semver::Version;
66

77
use mithril_common::{
88
entities::{
9-
ArtifactsLocations, CardanoDatabase, CardanoDbBeacon, Certificate, CompressionAlgorithm,
10-
ProtocolMessagePartKey, SignedEntityType,
9+
ArtifactsLocations, CardanoDatabaseSnapshot, CardanoDbBeacon, Certificate,
10+
CompressionAlgorithm, ProtocolMessagePartKey, SignedEntityType,
1111
},
1212
StdResult,
1313
};
@@ -35,12 +35,12 @@ impl CardanoDatabaseArtifactBuilder {
3535
}
3636

3737
#[async_trait]
38-
impl ArtifactBuilder<CardanoDbBeacon, CardanoDatabase> for CardanoDatabaseArtifactBuilder {
38+
impl ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot> for CardanoDatabaseArtifactBuilder {
3939
async fn compute_artifact(
4040
&self,
4141
beacon: CardanoDbBeacon,
4242
certificate: &Certificate,
43-
) -> StdResult<CardanoDatabase> {
43+
) -> StdResult<CardanoDatabaseSnapshot> {
4444
let merkle_root = certificate
4545
.protocol_message
4646
.get_message_part(&ProtocolMessagePartKey::CardanoDatabaseMerkleRoot)
@@ -55,7 +55,7 @@ impl ArtifactBuilder<CardanoDbBeacon, CardanoDatabase> for CardanoDatabaseArtifa
5555
})?;
5656
let total_db_size_uncompressed = compute_uncompressed_database_size(&self.db_directory)?;
5757

58-
let cardano_database = CardanoDatabase::new(
58+
let cardano_database = CardanoDatabaseSnapshot::new(
5959
merkle_root.to_string(),
6060
beacon,
6161
total_db_size_uncompressed,
@@ -195,12 +195,12 @@ mod tests {
195195
.await
196196
.unwrap();
197197

198-
let artifact_expected = CardanoDatabase::new(
198+
let artifact_expected = CardanoDatabaseSnapshot::new(
199199
"merkleroot".to_string(),
200200
beacon,
201201
expected_total_size,
202202
ArtifactsLocations {
203-
digests: vec![],
203+
digest: vec![],
204204
immutables: vec![],
205205
ancillary: vec![],
206206
},

mithril-aggregator/src/services/signed_entity.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use tokio::task::JoinHandle;
1111

1212
use mithril_common::{
1313
entities::{
14-
BlockNumber, CardanoDatabase, CardanoDbBeacon, CardanoStakeDistribution,
14+
BlockNumber, CardanoDatabaseSnapshot, CardanoDbBeacon, CardanoStakeDistribution,
1515
CardanoTransactionsSnapshot, Certificate, Epoch, MithrilStakeDistribution, SignedEntity,
1616
SignedEntityType, SignedEntityTypeDiscriminants, Snapshot,
1717
},
@@ -89,7 +89,8 @@ pub struct MithrilSignedEntityService {
8989
signed_entity_type_lock: Arc<SignedEntityTypeLock>,
9090
cardano_stake_distribution_artifact_builder:
9191
Arc<dyn ArtifactBuilder<Epoch, CardanoStakeDistribution>>,
92-
cardano_database_artifact_builder: Arc<dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabase>>,
92+
cardano_database_artifact_builder:
93+
Arc<dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot>>,
9394
metrics_service: Arc<MetricsService>,
9495
logger: Logger,
9596
}
@@ -104,7 +105,8 @@ pub struct SignedEntityServiceArtifactsDependencies {
104105
Arc<dyn ArtifactBuilder<BlockNumber, CardanoTransactionsSnapshot>>,
105106
cardano_stake_distribution_artifact_builder:
106107
Arc<dyn ArtifactBuilder<Epoch, CardanoStakeDistribution>>,
107-
cardano_database_artifact_builder: Arc<dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabase>>,
108+
cardano_database_artifact_builder:
109+
Arc<dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot>>,
108110
}
109111

110112
impl SignedEntityServiceArtifactsDependencies {
@@ -123,7 +125,7 @@ impl SignedEntityServiceArtifactsDependencies {
123125
dyn ArtifactBuilder<Epoch, CardanoStakeDistribution>,
124126
>,
125127
cardano_database_artifact_builder: Arc<
126-
dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabase>,
128+
dyn ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot>,
127129
>,
128130
) -> Self {
129131
Self {
@@ -523,7 +525,7 @@ mod tests {
523525
mock_cardano_stake_distribution_artifact_builder:
524526
MockArtifactBuilder<Epoch, CardanoStakeDistribution>,
525527
mock_cardano_database_artifact_builder:
526-
MockArtifactBuilder<CardanoDbBeacon, CardanoDatabase>,
528+
MockArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot>,
527529
}
528530

529531
impl MockDependencyInjector {
@@ -548,7 +550,7 @@ mod tests {
548550
>::new(),
549551
mock_cardano_database_artifact_builder: MockArtifactBuilder::<
550552
CardanoDbBeacon,
551-
CardanoDatabase,
553+
CardanoDatabaseSnapshot,
552554
>::new(),
553555
}
554556
}
@@ -845,7 +847,7 @@ mod tests {
845847
async fn build_cardano_database_artifact_when_given_cardano_database_entity_type() {
846848
let mut mock_container = MockDependencyInjector::new();
847849

848-
let cardano_database_expected = fake_data::cardano_database_entities(1)
850+
let cardano_database_expected = fake_data::cardano_database_snapshots(1)
849851
.first()
850852
.unwrap()
851853
.to_owned();
@@ -855,7 +857,7 @@ mod tests {
855857
.expect_compute_artifact()
856858
.times(1)
857859
.returning(|_, _| {
858-
Ok(fake_data::cardano_database_entities(1)
860+
Ok(fake_data::cardano_database_snapshots(1)
859861
.first()
860862
.unwrap()
861863
.to_owned())
@@ -877,7 +879,7 @@ mod tests {
877879
async fn should_store_the_artifact_when_creating_artifact_for_a_cardano_database() {
878880
generic_test_that_the_artifact_is_stored(
879881
SignedEntityType::CardanoDatabase(CardanoDbBeacon::default()),
880-
fake_data::cardano_database_entities(1)
882+
fake_data::cardano_database_snapshots(1)
881883
.first()
882884
.unwrap()
883885
.to_owned(),

mithril-common/src/entities/cardano_database.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ use crate::{
66
signable_builder::Artifact,
77
};
88

9-
/// Cardano database incremental.
9+
/// Cardano database snapshot.
1010
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
11-
pub struct CardanoDatabase {
12-
/// Merkle root of the Cardano database.
11+
pub struct CardanoDatabaseSnapshot {
12+
/// Merkle root of the Cardano database snapshot.
1313
pub merkle_root: String,
1414

1515
/// Mithril beacon on the Cardano chain.
1616
pub beacon: CardanoDbBeacon,
1717

18-
/// Size of the uncompressed Cardano database (including the ledger and volatile) in Bytes.
18+
/// Size of the uncompressed Cardano database files.
1919
pub total_db_size_uncompressed: u64,
2020

2121
/// Locations of the Cardano database artifacts.
2222
pub locations: ArtifactsLocations,
2323

24-
/// Compression algorithm of the Cardano database archives
24+
/// Compression algorithm of the Cardano database artifacts.
2525
pub compression_algorithm: CompressionAlgorithm,
2626

27-
/// Version of the Cardano node used to create the archives.
27+
/// Version of the Cardano node used to create the snapshot.
2828
pub cardano_node_version: String,
2929
}
3030

31-
impl CardanoDatabase {
32-
/// [CardanoDatabase] factory
31+
impl CardanoDatabaseSnapshot {
32+
/// [CardanoDatabaseSnapshot] factory
3333
pub fn new(
3434
merkle_root: String,
3535
beacon: CardanoDbBeacon,
@@ -60,16 +60,16 @@ pub enum ArtifactLocation {
6060
/// Locations of the Cardano database related files.
6161
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
6262
pub struct ArtifactsLocations {
63-
/// Locations of the file containing the digests of the immutable files.
64-
pub digests: Vec<ArtifactLocation>,
63+
/// Locations of the the immutable file digests.
64+
pub digest: Vec<ArtifactLocation>,
6565
/// Locations of the immutable files.
6666
pub immutables: Vec<ArtifactLocation>,
6767
/// Locations of the ancillary files (ledger and volatile).
6868
pub ancillary: Vec<ArtifactLocation>,
6969
}
7070

7171
#[typetag::serde]
72-
impl Artifact for CardanoDatabase {
72+
impl Artifact for CardanoDatabaseSnapshot {
7373
fn get_id(&self) -> String {
7474
self.merkle_root.clone()
7575
}

mithril-common/src/entities/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mod type_alias;
3333
pub use block_number::BlockNumber;
3434
pub use block_range::{BlockRange, BlockRangeLength, BlockRangesSequence};
3535
pub use cardano_chain_point::{BlockHash, ChainPoint};
36-
pub use cardano_database::{ArtifactsLocations, CardanoDatabase};
36+
pub use cardano_database::{ArtifactsLocations, CardanoDatabaseSnapshot};
3737
pub use cardano_db_beacon::CardanoDbBeacon;
3838
pub use cardano_network::CardanoNetwork;
3939
pub use cardano_stake_distribution::CardanoStakeDistribution;

mithril-common/src/test_utils/fake_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ pub fn cardano_stake_distribution(epoch: Epoch) -> entities::CardanoStakeDistrib
278278
}
279279
}
280280

281-
/// Fake Cardano Database entities
282-
pub fn cardano_database_entities(total: u64) -> Vec<entities::CardanoDatabase> {
281+
/// Fake Cardano Database snapshots
282+
pub fn cardano_database_snapshots(total: u64) -> Vec<entities::CardanoDatabaseSnapshot> {
283283
(1..total + 1)
284284
.map(|cardano_database_id| {
285285
let merkle_root = format!("1{cardano_database_id}").repeat(20);
@@ -289,7 +289,7 @@ pub fn cardano_database_entities(total: u64) -> Vec<entities::CardanoDatabase> {
289289
let cardano_node_version = Version::parse("1.0.0").unwrap();
290290
let locations = ArtifactsLocations::default();
291291

292-
entities::CardanoDatabase::new(
292+
entities::CardanoDatabaseSnapshot::new(
293293
merkle_root,
294294
beacon,
295295
total_db_size_uncompressed,
@@ -298,5 +298,5 @@ pub fn cardano_database_entities(total: u64) -> Vec<entities::CardanoDatabase> {
298298
&cardano_node_version,
299299
)
300300
})
301-
.collect::<Vec<entities::CardanoDatabase>>()
301+
.collect::<Vec<entities::CardanoDatabaseSnapshot>>()
302302
}

0 commit comments

Comments
 (0)