File tree Expand file tree Collapse file tree 2 files changed +40
-26
lines changed Expand file tree Collapse file tree 2 files changed +40
-26
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ use std::{
4
4
sync:: Arc ,
5
5
} ;
6
6
7
- use anyhow:: Context ;
7
+ use anyhow:: { Context , anyhow } ;
8
8
use chrono:: Utc ;
9
9
use clap:: Parser ;
10
- use mithril_client:: MithrilResult ;
10
+ use mithril_client:: { ComputeCardanoDatabaseMessageError , MithrilResult } ;
11
11
12
12
use crate :: {
13
13
CommandContext ,
@@ -122,26 +122,37 @@ impl CardanoDbVerifyCommand {
122
122
db_dir,
123
123
& verified_digests,
124
124
)
125
- . await ?;
126
-
127
- shared_steps:: verify_message_matches_certificate (
128
- & context. logger ( ) . clone ( ) ,
129
- 4 ,
130
- & progress_printer,
131
- & certificate,
132
- & message,
133
- & cardano_db_message,
134
- db_dir,
135
- )
136
- . await ?;
137
-
138
- Self :: log_verified_information (
139
- db_dir,
140
- & cardano_db_message. hash ,
141
- context. is_json_output_enabled ( ) ,
142
- ) ?;
143
-
144
- Ok ( ( ) )
125
+ . await ;
126
+
127
+ match message {
128
+ Err ( e) => match e. downcast_ref :: < ComputeCardanoDatabaseMessageError > ( ) {
129
+ Some ( ComputeCardanoDatabaseMessageError :: ImmutableFilesVerification ( lists) ) => {
130
+ // let missing_files = lists.missing;
131
+ Ok ( ( ) )
132
+ }
133
+ _ => Err ( e) ,
134
+ } ,
135
+ Ok ( message) => {
136
+ shared_steps:: verify_message_matches_certificate (
137
+ & context. logger ( ) . clone ( ) ,
138
+ 4 ,
139
+ & progress_printer,
140
+ & certificate,
141
+ & message,
142
+ & cardano_db_message,
143
+ db_dir,
144
+ )
145
+ . await ?;
146
+
147
+ Self :: log_verified_information (
148
+ db_dir,
149
+ & cardano_db_message. hash ,
150
+ context. is_json_output_enabled ( ) ,
151
+ ) ?;
152
+
153
+ Ok ( ( ) )
154
+ }
155
+ }
145
156
}
146
157
147
158
fn log_verified_information (
Original file line number Diff line number Diff line change @@ -22,10 +22,13 @@ impl CardanoDbUtils {
22
22
}
23
23
24
24
/// Display a spinner while waiting for the result of a future
25
- pub async fn wait_spinner < T > (
25
+ pub async fn wait_spinner < T , E > (
26
26
progress_bar : & MultiProgress ,
27
- future : impl Future < Output = MithrilResult < T > > ,
28
- ) -> MithrilResult < T > {
27
+ future : impl Future < Output = Result < T , E > > ,
28
+ ) -> MithrilResult < T >
29
+ where
30
+ MithrilError : From < E > ,
31
+ {
29
32
let pb = progress_bar. add ( ProgressBar :: new_spinner ( ) ) ;
30
33
let spinner = async move {
31
34
loop {
@@ -36,7 +39,7 @@ impl CardanoDbUtils {
36
39
37
40
tokio:: select! {
38
41
_ = spinner => Err ( anyhow!( "timeout" ) ) ,
39
- res = future => res,
42
+ res = future => res. map_err ( Into :: into ) ,
40
43
}
41
44
}
42
45
You can’t perform that action at this time.
0 commit comments