Skip to content

Commit 7cf0b3e

Browse files
committed
refactor: add type conversion generic to CardanoTransactionsSetProof factory
1 parent 46d34c2 commit 7cf0b3e

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ mod tests {
8282
.chunks(2)
8383
.map(|transaction_hashes_in_chunk| {
8484
let mk_proof = MKProof::from_leaves(transaction_hashes_in_chunk).unwrap();
85-
CardanoTransactionsSetProof::new(
86-
transaction_hashes_in_chunk.to_vec(),
87-
mk_proof.into(),
88-
)
85+
CardanoTransactionsSetProof::new(transaction_hashes_in_chunk.to_vec(), mk_proof)
8986
})
9087
.collect::<Vec<_>>();
9188

mithril-common/src/entities/cardano_transactions_set_proof.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ pub struct CardanoTransactionsSetProof {
1717

1818
impl CardanoTransactionsSetProof {
1919
/// CardanoTransactionsSetProof factory
20-
pub fn new(
20+
pub fn new<T: Into<MKMapProof<BlockRange>>>(
2121
transactions_hashes: Vec<TransactionHash>,
22-
transactions_proof: MKMapProof<BlockRange>,
22+
transactions_proof: T,
2323
) -> Self {
2424
Self {
2525
transactions_hashes,
26-
transactions_proof: ProtocolMkProof::new(transactions_proof),
26+
transactions_proof: ProtocolMkProof::new(transactions_proof.into()),
2727
}
2828
}
2929

mithril-common/src/messages/cardano_transactions_proof.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ mod tests {
264264
fn verify_invalid_proofs() {
265265
let set_proof = CardanoTransactionsSetProof::new(
266266
vec!["invalid1".to_string()],
267-
MKProof::from_leaves(&["invalid2"]).unwrap().into(),
267+
MKProof::from_leaves(&["invalid2"]).unwrap(),
268268
);
269269
let txs_proofs = CardanoTransactionsProofsMessage::new(
270270
"whatever",
@@ -292,11 +292,11 @@ mod tests {
292292
let set_proofs = vec![
293293
CardanoTransactionsSetProof::new(
294294
vec!["tx-1".to_string()],
295-
MKProof::from_leaves(&["tx-1"]).unwrap().into(),
295+
MKProof::from_leaves(&["tx-1"]).unwrap(),
296296
),
297297
CardanoTransactionsSetProof::new(
298298
vec!["tx-2".to_string()],
299-
MKProof::from_leaves(&["tx-2"]).unwrap().into(),
299+
MKProof::from_leaves(&["tx-2"]).unwrap(),
300300
),
301301
];
302302
let txs_proofs = CardanoTransactionsProofsMessage::new(
@@ -356,7 +356,7 @@ mod tests {
356356
.collect::<Vec<_>>();
357357

358358
let proof = MKProof::from_leaves(transactions).unwrap();
359-
let set_proof = CardanoTransactionsSetProof::new(transactions_hashes, proof.into());
359+
let set_proof = CardanoTransactionsSetProof::new(transactions_hashes, proof);
360360

361361
let verified_transactions_fake = VerifiedCardanoTransactions {
362362
certificate_hash: "whatever".to_string(),

0 commit comments

Comments
 (0)