Skip to content

Commit 7ae9a6c

Browse files
committed
refacto: remove entities dependency to signable_builder
Move `signed_entity` to `signable_builder` module. Move `Beacon` and `Artifact` implementations in `signable_builder` module.
1 parent 2445ee9 commit 7ae9a6c

File tree

19 files changed

+75
-87
lines changed

19 files changed

+75
-87
lines changed

mithril-aggregator/src/database/record/signed_entity.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use serde::{Deserialize, Serialize};
33

44
use mithril_common::crypto_helper::ProtocolParameters;
55
use mithril_common::entities::{
6-
BlockNumber, CardanoDatabaseSnapshot, Epoch, SignedEntity, SignedEntityType, Snapshot,
7-
StakeDistribution,
6+
BlockNumber, CardanoDatabaseSnapshot, Epoch, SignedEntityType, Snapshot, StakeDistribution,
87
};
98
#[cfg(test)]
109
use mithril_common::entities::{CardanoStakeDistribution, MithrilStakeDistribution};
@@ -15,7 +14,7 @@ use mithril_common::messages::{
1514
MithrilStakeDistributionListItemMessage, MithrilStakeDistributionMessage,
1615
SignerWithStakeMessagePart, SnapshotListItemMessage, SnapshotMessage,
1716
};
18-
use mithril_common::signable_builder::Artifact;
17+
use mithril_common::signable_builder::{Artifact, SignedEntity};
1918
use mithril_common::StdError;
2019
use mithril_persistence::database::Hydrator;
2120
use mithril_persistence::sqlite::{HydrationError, Projection, SqLiteEntity};

mithril-aggregator/src/database/repository/signed_entity_store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl SignedEntityStorer for SignedEntityStore {
165165
#[cfg(test)]
166166
mod tests {
167167
use mithril_common::{
168-
entities::{Epoch, MithrilStakeDistribution, SignedEntity, Snapshot},
168+
entities::{Epoch, MithrilStakeDistribution, Snapshot},
169+
signable_builder::SignedEntity,
169170
test_utils::fake_data,
170171
};
171172

mithril-aggregator/src/http_server/routes/artifact_routes/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub mod snapshot;
77
#[cfg(test)]
88
pub mod test_utils {
99
use chrono::{DateTime, Utc};
10-
use mithril_common::entities::{SignedEntity, SignedEntityType};
11-
use mithril_common::signable_builder::Artifact;
10+
use mithril_common::entities::SignedEntityType;
11+
use mithril_common::signable_builder::{Artifact, SignedEntity};
1212

1313
pub fn create_signed_entity<T>(
1414
signed_entity_type: SignedEntityType,

mithril-aggregator/src/http_server/routes/proof_routes.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ fn proof_cardano_transaction(
4848

4949
mod handlers {
5050
use mithril_common::{
51-
entities::{CardanoTransactionsSnapshot, SignedEntity},
52-
messages::CardanoTransactionsProofsMessage,
53-
StdResult,
51+
entities::CardanoTransactionsSnapshot, messages::CardanoTransactionsProofsMessage,
52+
signable_builder::SignedEntity, StdResult,
5453
};
5554
use slog::{debug, warn, Logger};
5655
use std::{convert::Infallible, sync::Arc};
@@ -148,9 +147,8 @@ mod tests {
148147
};
149148

150149
use mithril_common::{
151-
entities::{
152-
BlockNumber, CardanoTransactionsSetProof, CardanoTransactionsSnapshot, SignedEntity,
153-
},
150+
entities::{BlockNumber, CardanoTransactionsSetProof, CardanoTransactionsSnapshot},
151+
signable_builder::SignedEntity,
154152
test_utils::{apispec::APISpec, assert_equivalent, fake_data},
155153
};
156154

mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use mithril_common::entities::{CardanoTransactionsSnapshot, SignedEntity};
2-
use mithril_common::messages::CardanoTransactionsSetProofMessagePart;
31
use mithril_common::{
4-
entities::{CardanoTransactionsSetProof, TransactionHash},
5-
messages::CardanoTransactionsProofsMessage,
2+
entities::{CardanoTransactionsSetProof, CardanoTransactionsSnapshot, TransactionHash},
3+
messages::{CardanoTransactionsProofsMessage, CardanoTransactionsSetProofMessagePart},
4+
signable_builder::SignedEntity,
65
StdResult,
76
};
87

mithril-aggregator/src/services/signed_entity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use tokio::task::JoinHandle;
1212
use mithril_common::{
1313
entities::{
1414
BlockNumber, CardanoDatabaseSnapshot, CardanoDbBeacon, CardanoStakeDistribution,
15-
CardanoTransactionsSnapshot, Certificate, Epoch, MithrilStakeDistribution, SignedEntity,
15+
CardanoTransactionsSnapshot, Certificate, Epoch, MithrilStakeDistribution,
1616
SignedEntityType, SignedEntityTypeDiscriminants, Snapshot,
1717
},
1818
logging::LoggerExtensions,
19-
signable_builder::Artifact,
19+
signable_builder::{Artifact, SignedEntity},
2020
signed_entity_type_lock::SignedEntityTypeLock,
2121
StdResult,
2222
};

mithril-aggregator/tests/test_extensions/aggregator_observer.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ use mithril_aggregator::{
44
entities::OpenMessage,
55
services::{CertifierService, SignedEntityService},
66
};
7-
use mithril_common::entities::{CardanoTransactionsSnapshot, Certificate, SignedEntity};
87
use mithril_common::{
9-
entities::{Epoch, SignedEntityType, SignedEntityTypeDiscriminants, TimePoint},
8+
entities::{
9+
CardanoTransactionsSnapshot, Certificate, Epoch, SignedEntityType,
10+
SignedEntityTypeDiscriminants, TimePoint,
11+
},
12+
signable_builder::SignedEntity,
1013
StdResult, TickerService,
1114
};
1215
use std::sync::Arc;

mithril-common/src/entities/block_number.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::entities::arithmetic_operation_wrapper::{
88
impl_add_to_wrapper, impl_div_to_wrapper, impl_mul_to_wrapper, impl_partial_eq_to_wrapper,
99
impl_rem_to_wrapper, impl_sub_to_wrapper,
1010
};
11-
use crate::signable_builder::Beacon;
1211

1312
#[cfg(target_family = "wasm")]
1413
use wasm_bindgen::prelude::*;
@@ -20,8 +19,6 @@ use wasm_bindgen::prelude::*;
2019
#[cfg_attr(target_family = "wasm", wasm_bindgen)]
2120
pub struct BlockNumber(pub u64);
2221

23-
impl Beacon for BlockNumber {}
24-
2522
impl Display for BlockNumber {
2623
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2724
write!(f, "{}", self.0)

mithril-common/src/entities/cardano_database.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use semver::Version;
22
use serde::{Deserialize, Serialize};
33
use sha2::{Digest, Sha256};
44

5-
use crate::{
6-
entities::{CardanoDbBeacon, CompressionAlgorithm},
7-
signable_builder::Artifact,
8-
};
5+
use crate::entities::{CardanoDbBeacon, CompressionAlgorithm};
96

107
use super::MultiFilesUri;
118

@@ -120,13 +117,6 @@ pub struct ArtifactsLocations {
120117
pub ancillary: Vec<AncillaryLocation>,
121118
}
122119

123-
#[typetag::serde]
124-
impl Artifact for CardanoDatabaseSnapshot {
125-
fn get_id(&self) -> String {
126-
self.hash.clone()
127-
}
128-
}
129-
130120
#[cfg(test)]
131121
mod tests {
132122
use super::*;

mithril-common/src/entities/cardano_db_beacon.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use sha2::{Digest, Sha256};
33
use std::fmt::{Display, Formatter};
44

55
use crate::entities::{Epoch, ImmutableFileNumber};
6-
use crate::signable_builder::Beacon;
76

87
/// A point in the Cardano chain at which a Mithril certificate of the Cardano Database should be
98
/// produced.
@@ -16,8 +15,6 @@ pub struct CardanoDbBeacon {
1615
pub immutable_file_number: ImmutableFileNumber,
1716
}
1817

19-
impl Beacon for CardanoDbBeacon {}
20-
2118
impl Display for CardanoDbBeacon {
2219
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2320
write!(

0 commit comments

Comments
 (0)