@@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
6
6
use mithril_client:: {
7
7
CardanoDatabaseSnapshot , Client , MessageBuilder , MithrilCertificate , MithrilResult ,
8
8
cardano_database_client:: { ImmutableFileRange , VerifiedDigests } ,
9
- common:: { ImmutableFileNumber , ProtocolMessage } ,
9
+ common:: { ImmutableFileNumber , MKProof , ProtocolMessage } ,
10
10
} ;
11
11
12
12
use crate :: utils:: { CardanoDbUtils , ProgressPrinter } ;
@@ -69,19 +69,19 @@ pub async fn download_and_verify_digests(
69
69
Ok ( verified_digests)
70
70
}
71
71
72
- /// Computes the Cardano database snapshot message using the provided certificate and Merkle proof.
73
- pub async fn compute_cardano_db_snapshot_message (
72
+ pub async fn verify_cardano_database (
74
73
step_number : u16 ,
75
74
progress_printer : & ProgressPrinter ,
75
+ client : & Client ,
76
76
certificate : & MithrilCertificate ,
77
77
cardano_database_snapshot : & CardanoDatabaseSnapshot ,
78
78
options : & ComputeCardanoDatabaseMessageOptions ,
79
79
verified_digest : & VerifiedDigests ,
80
- ) -> MithrilResult < ProtocolMessage > {
81
- progress_printer. report_step ( step_number, "Computing the cardano db snapshot message " ) ?;
82
- let message = CardanoDbUtils :: wait_spinner (
80
+ ) -> MithrilResult < MKProof > {
81
+ progress_printer. report_step ( step_number, "Verifying the cardano database " ) ?;
82
+ let merkle_proof = CardanoDbUtils :: wait_spinner (
83
83
progress_printer,
84
- MessageBuilder :: new ( ) . compute_cardano_database_message (
84
+ client . cardano_database_v2 ( ) . verify_cardano_database (
85
85
certificate,
86
86
cardano_database_snapshot,
87
87
& options. immutable_file_range ,
@@ -91,6 +91,24 @@ pub async fn compute_cardano_db_snapshot_message(
91
91
) ,
92
92
)
93
93
. await
94
+ . with_context ( || "Can not verify the cardano database" ) ?;
95
+
96
+ Ok ( merkle_proof)
97
+ }
98
+
99
+ /// Computes the Cardano database snapshot message using the provided certificate and Merkle proof.
100
+ pub async fn compute_cardano_db_snapshot_message (
101
+ step_number : u16 ,
102
+ progress_printer : & ProgressPrinter ,
103
+ certificate : & MithrilCertificate ,
104
+ merkle_proof : & MKProof ,
105
+ ) -> MithrilResult < ProtocolMessage > {
106
+ progress_printer. report_step ( step_number, "Computing the cardano db snapshot message" ) ?;
107
+ let message = CardanoDbUtils :: wait_spinner (
108
+ progress_printer,
109
+ MessageBuilder :: new ( ) . compute_cardano_database_message ( certificate, merkle_proof) ,
110
+ )
111
+ . await
94
112
. with_context ( || "Can not compute the cardano db snapshot message" ) ?;
95
113
96
114
Ok ( message)
0 commit comments