@@ -28,6 +28,9 @@ use mithril_common::{
28
28
signable_builder:: CardanoStakeDistributionSignableBuilder ,
29
29
} ;
30
30
31
+ #[ cfg( feature = "fs" ) ]
32
+ use mithril_common:: crypto_helper:: MKProof ;
33
+
31
34
use crate :: {
32
35
CardanoStakeDistribution , MithrilCertificate , MithrilResult , MithrilSigner ,
33
36
MithrilStakeDistribution , VerifiedCardanoTransactions ,
@@ -240,12 +243,27 @@ impl MessageBuilder {
240
243
missing_files
241
244
}
242
245
246
+ /// Compute message for a Cardano database.
247
+ pub async fn compute_cardano_database_message(
248
+ & self ,
249
+ certificate: & MithrilCertificate ,
250
+ merkle_proof: & MKProof ,
251
+ ) -> MithrilResult <ProtocolMessage > {
252
+ let mut message = certificate. protocol_message. clone( ) ;
253
+ message. set_message_part(
254
+ ProtocolMessagePartKey :: CardanoDatabaseMerkleRoot ,
255
+ merkle_proof. root( ) . to_hex( ) ,
256
+ ) ;
257
+ Ok ( message)
258
+ }
259
+
260
+
243
261
///TODO: TO REMOVE
244
262
/// Compute message for a Cardano database.
245
263
///
246
264
/// This function first lists missing immutables files (if `allow_missing` is false)
247
265
/// then computes the digests for the given range and finally computes the Merkle proof.
248
- pub async fn compute_cardano_database_message (
266
+ pub async fn compute_cardano_database_message_OLD (
249
267
& self ,
250
268
certificate: & CertificateMessage ,
251
269
cardano_database_snapshot: & CardanoDatabaseSnapshotMessage ,
@@ -558,7 +576,7 @@ mod tests {
558
576
. await ;
559
577
560
578
let message = MessageBuilder :: new ( )
561
- . compute_cardano_database_message (
579
+ . compute_cardano_database_message_OLD (
562
580
& certificate,
563
581
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
564
582
& immutable_file_range_to_prove,
@@ -594,7 +612,7 @@ mod tests {
594
612
595
613
let allow_missing = false ;
596
614
let error = MessageBuilder :: new ( )
597
- . compute_cardano_database_message (
615
+ . compute_cardano_database_message_OLD (
598
616
& certificate,
599
617
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
600
618
& immutable_file_range_to_prove,
@@ -644,7 +662,7 @@ mod tests {
644
662
645
663
let allow_missing = true ;
646
664
MessageBuilder :: new ( )
647
- . compute_cardano_database_message (
665
+ . compute_cardano_database_message_OLD (
648
666
& certificate,
649
667
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
650
668
& immutable_file_range_to_prove,
@@ -680,7 +698,7 @@ mod tests {
680
698
681
699
let error = MessageBuilder :: new ( )
682
700
. with_logger ( logger)
683
- . compute_cardano_database_message (
701
+ . compute_cardano_database_message_OLD (
684
702
& certificate,
685
703
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
686
704
& immutable_file_range_to_prove,
@@ -733,7 +751,7 @@ mod tests {
733
751
tamper_immutable_files ( & database_dir, & files_to_tamper) ;
734
752
735
753
let error = MessageBuilder :: new ( )
736
- . compute_cardano_database_message (
754
+ . compute_cardano_database_message_OLD (
737
755
& certificate,
738
756
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
739
757
& immutable_file_range_to_prove,
@@ -800,7 +818,7 @@ mod tests {
800
818
. await ;
801
819
802
820
let error = MessageBuilder :: new ( )
803
- . compute_cardano_database_message (
821
+ . compute_cardano_database_message_OLD (
804
822
& certificate,
805
823
& CardanoDatabaseSnapshotMessage :: dummy ( ) ,
806
824
& ImmutableFileRange :: Range ( 1 , 15 ) ,
0 commit comments