@@ -7,7 +7,7 @@ use std::{
77use anyhow:: { Context , anyhow} ;
88use chrono:: Utc ;
99use clap:: Parser ;
10- use mithril_client:: { ComputeCardanoDatabaseMessageError , MithrilResult } ;
10+ use mithril_client:: { ComputeCardanoDatabaseMessageError , ImmutableFilesLists , MithrilResult } ;
1111
1212use crate :: {
1313 CommandContext ,
@@ -129,6 +129,10 @@ impl CardanoDbVerifyCommand {
129129 Err ( e) => match e. downcast_ref :: < ComputeCardanoDatabaseMessageError > ( ) {
130130 Some ( ComputeCardanoDatabaseMessageError :: ImmutableFilesVerification ( lists) ) => {
131131 // let missing_files = lists.missing;
132+ Self :: print_immutables_verification_error (
133+ lists,
134+ context. is_json_output_enabled ( ) ,
135+ ) ;
132136 Ok ( ( ) )
133137 }
134138 _ => Err ( anyhow ! ( e) ) ,
@@ -177,6 +181,27 @@ impl CardanoDbVerifyCommand {
177181 }
178182 Ok ( ( ) )
179183 }
184+
185+ fn print_immutables_verification_error ( lists : & ImmutableFilesLists , json_output : bool ) {
186+ if json_output {
187+ let json = serde_json:: json!( {
188+ "timestamp" : Utc :: now( ) . to_rfc3339( ) ,
189+ "immutables_dir" : lists. immutables_dir,
190+ "missing_files" : lists. missing,
191+ "tampered_files" : lists. tampered,
192+ } ) ;
193+ println ! ( "{json}" ) ;
194+ } else {
195+ println ! (
196+ r###"computing cardano database message from immutables files has failed:
197+ - missing files: {}
198+ - tampered files: {}
199+ "### ,
200+ lists. missing. len( ) ,
201+ lists. tampered. len( )
202+ ) ;
203+ }
204+ }
180205}
181206
182207impl ConfigSource for CardanoDbVerifyCommand {
0 commit comments