Skip to content

Commit 2c495f7

Browse files
committed
Fix backward compatibility for Snapshot as Signed Entity
1 parent 179bc23 commit 2c495f7

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/src/artifact_builder/artifact_builder_service.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use async_trait::async_trait;
22
use chrono::Utc;
3-
use uuid::Uuid;
43

54
use std::sync::Arc;
65

@@ -94,7 +93,7 @@ impl ArtifactBuilderService for MithrilArtifactBuilderService {
9493
artifact: Arc<dyn Artifact>,
9594
) -> StdResult<()> {
9695
let signed_entity = SignedEntityRecord {
97-
signed_entity_id: Uuid::new_v4().to_string(),
96+
signed_entity_id: artifact.get_id(),
9897
signed_entity_type,
9998
certificate_id: certificate.hash.clone(),
10099
entity: serde_json::to_string(&artifact)?,

mithril-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ strum_macros = "0.24.1"
5050
thiserror = "1.0.31"
5151
tokio = { version = "1.17.0", features = ["full"] }
5252
typetag = "0.2.8"
53+
uuid = { version = "1.3.0", features = ["v4", "fast-rng", "macro-diagnostics"] }
5354
walkdir = "2"
5455
warp = "0.3"
5556

mithril-common/src/entities/snapshot.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ impl Snapshot {
4545
}
4646

4747
#[typetag::serde]
48-
impl Artifact for Snapshot {}
48+
impl Artifact for Snapshot {
49+
fn get_id(&self) -> String {
50+
self.digest.clone()
51+
}
52+
}

mithril-common/src/signable_builder/interface.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use async_trait::async_trait;
22
use std::fmt::Debug;
3+
use uuid::Uuid;
34

45
use crate::{entities::ProtocolMessage, StdResult};
56

@@ -11,7 +12,12 @@ pub trait Beacon: Send + Sync {}
1112

1213
/// Artifact is a trait for types that represent signed artifacts
1314
#[typetag::serde(tag = "type")]
14-
pub trait Artifact: Debug + Send + Sync {}
15+
pub trait Artifact: Debug + Send + Sync {
16+
/// Get artifact identifier
17+
fn get_id(&self) -> String {
18+
Uuid::new_v4().to_string()
19+
}
20+
}
1521

1622
/// SignableBuilder is trait for building a protocol message for a beacon
1723
#[cfg_attr(test, automock)]

0 commit comments

Comments
 (0)