@@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
66use mithril_client:: {
77 CardanoDatabaseSnapshot , Client , MessageBuilder , MithrilCertificate , MithrilResult ,
88 cardano_database_client:: { ImmutableFileRange , VerifiedDigests } ,
9- common:: { ImmutableFileNumber , ProtocolMessage } ,
9+ common:: { ImmutableFileNumber , MKProof , ProtocolMessage } ,
1010} ;
1111
1212use crate :: utils:: { CardanoDbUtils , ProgressPrinter } ;
@@ -69,19 +69,19 @@ pub async fn download_and_verify_digests(
6969 Ok ( verified_digests)
7070}
7171
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 (
7473 step_number : u16 ,
7574 progress_printer : & ProgressPrinter ,
75+ client : & Client ,
7676 certificate : & MithrilCertificate ,
7777 cardano_database_snapshot : & CardanoDatabaseSnapshot ,
7878 options : & ComputeCardanoDatabaseMessageOptions ,
7979 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 (
8383 progress_printer,
84- MessageBuilder :: new ( ) . compute_cardano_database_message (
84+ client . cardano_database_v2 ( ) . verify_cardano_database (
8585 certificate,
8686 cardano_database_snapshot,
8787 & options. immutable_file_range ,
@@ -91,6 +91,24 @@ pub async fn compute_cardano_db_snapshot_message(
9191 ) ,
9292 )
9393 . 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
94112 . with_context ( || "Can not compute the cardano db snapshot message" ) ?;
95113
96114 Ok ( message)
0 commit comments