@@ -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 ,
@@ -129,6 +129,10 @@ impl CardanoDbVerifyCommand {
129
129
Err ( e) => match e. downcast_ref :: < ComputeCardanoDatabaseMessageError > ( ) {
130
130
Some ( ComputeCardanoDatabaseMessageError :: ImmutableFilesVerification ( lists) ) => {
131
131
// let missing_files = lists.missing;
132
+ Self :: print_immutables_verification_error (
133
+ lists,
134
+ context. is_json_output_enabled ( ) ,
135
+ ) ;
132
136
Ok ( ( ) )
133
137
}
134
138
_ => Err ( anyhow ! ( e) ) ,
@@ -177,6 +181,27 @@ impl CardanoDbVerifyCommand {
177
181
}
178
182
Ok ( ( ) )
179
183
}
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
+ }
180
205
}
181
206
182
207
impl ConfigSource for CardanoDbVerifyCommand {
0 commit comments