@@ -7,7 +7,7 @@ use std::{
7
7
use anyhow:: { Context , anyhow} ;
8
8
use chrono:: Utc ;
9
9
use clap:: Parser ;
10
- use mithril_client:: { ComputeCardanoDatabaseMessageError , MithrilResult } ;
10
+ use mithril_client:: { ComputeCardanoDatabaseMessageError , ImmutableFilesLists , MithrilResult } ;
11
11
12
12
use crate :: {
13
13
CommandContext ,
@@ -128,6 +128,10 @@ impl CardanoDbVerifyCommand {
128
128
Err ( e) => match e. downcast_ref :: < ComputeCardanoDatabaseMessageError > ( ) {
129
129
Some ( ComputeCardanoDatabaseMessageError :: ImmutableFilesVerification ( lists) ) => {
130
130
// let missing_files = lists.missing;
131
+ Self :: print_immutables_verification_error (
132
+ lists,
133
+ context. is_json_output_enabled ( ) ,
134
+ ) ;
131
135
Ok ( ( ) )
132
136
}
133
137
_ => Err ( anyhow ! ( e) ) ,
@@ -176,6 +180,27 @@ impl CardanoDbVerifyCommand {
176
180
}
177
181
Ok ( ( ) )
178
182
}
183
+
184
+ fn print_immutables_verification_error ( lists : & ImmutableFilesLists , json_output : bool ) {
185
+ if json_output {
186
+ let json = serde_json:: json!( {
187
+ "timestamp" : Utc :: now( ) . to_rfc3339( ) ,
188
+ "immutables_dir" : lists. immutables_dir,
189
+ "missing_files" : lists. missing,
190
+ "tampered_files" : lists. tampered,
191
+ } ) ;
192
+ println ! ( "{json}" ) ;
193
+ } else {
194
+ println ! (
195
+ r###"computing cardano database message from immutables files has failed:
196
+ - missing files: {}
197
+ - tampered files: {}
198
+ "### ,
199
+ lists. missing. len( ) ,
200
+ lists. tampered. len( )
201
+ ) ;
202
+ }
203
+ }
179
204
}
180
205
181
206
impl ConfigSource for CardanoDbVerifyCommand {
0 commit comments