mithril_common/entities/
cardano_database.rsuse semver::Version;
use serde::{Deserialize, Serialize};
use strum::EnumDiscriminants;
use crate::{
entities::{CardanoDbBeacon, CompressionAlgorithm},
signable_builder::Artifact,
};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CardanoDatabaseSnapshot {
pub merkle_root: String,
pub beacon: CardanoDbBeacon,
pub total_db_size_uncompressed: u64,
pub locations: ArtifactsLocations,
pub compression_algorithm: CompressionAlgorithm,
pub cardano_node_version: String,
}
impl CardanoDatabaseSnapshot {
pub fn new(
merkle_root: String,
beacon: CardanoDbBeacon,
total_db_size_uncompressed: u64,
locations: ArtifactsLocations,
compression_algorithm: CompressionAlgorithm,
cardano_node_version: &Version,
) -> Self {
let cardano_node_version = format!("{cardano_node_version}");
Self {
merkle_root,
beacon,
locations,
total_db_size_uncompressed,
compression_algorithm,
cardano_node_version,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum DigestLocation {
Aggregator {
uri: String,
},
CloudStorage {
uri: String,
},
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum ImmutablesLocation {
CloudStorage {
uri: String,
},
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, EnumDiscriminants)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum AncillaryLocation {
CloudStorage {
uri: String,
},
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct ArtifactsLocations {
pub digests: Vec<DigestLocation>,
pub immutables: Vec<ImmutablesLocation>,
pub ancillary: Vec<AncillaryLocation>,
}
#[typetag::serde]
impl Artifact for CardanoDatabaseSnapshot {
fn get_id(&self) -> String {
self.merkle_root.clone()
}
}