@@ -29,12 +29,12 @@ impl ProcessGuard {
29
29
}
30
30
31
31
// kills subprocess (here autct) on shutdown.
32
- // while this can cause substantial delays, we otherwise
33
- // would need to sync a previously running process
34
- // with current config, which is a bunch more mess.
32
+ // While it would be more convenient to allow
33
+ // attaching to a pre-existing server, to prevent
34
+ // startup delays, this is simpler for now, and
35
+ // avoids potential confusion/more code logic.
35
36
impl Drop for ProcessGuard {
36
37
fn drop ( & mut self ) {
37
- println ! ( "drop is getting called now" ) ;
38
38
// TODO is it even possible to
39
39
// handle the case where kill fails to kill?
40
40
let _ = self . child . kill ( ) ;
@@ -46,7 +46,6 @@ struct Wrapper {
46
46
wrapped_app : Arc < RwLock < AutctVerifierApp > > ,
47
47
}
48
48
49
-
50
49
struct AutctVerifierApp {
51
50
autctcfg : Option < AutctConfig > ,
52
51
sigmessage : Option < String > ,
@@ -68,7 +67,6 @@ struct AutctVerifierApp {
68
67
verif_result : Arc < Mutex < Option < String > > > ,
69
68
// this remembers the last RPC response we saw:
70
69
last_verif_result : Option < String > ,
71
- verif_runtime : Arc < Runtime > ,
72
70
server_state : Arc < Mutex < ServerState > > ,
73
71
autct_process_guard : Option < ProcessGuard > ,
74
72
}
@@ -85,11 +83,11 @@ enum ServerState {
85
83
86
84
#[ tokio:: main]
87
85
async fn main ( ) -> eframe:: Result {
88
- // make a read-only copy of the app for the
89
- // monitoring thread:
90
86
let mut myapp = AutctVerifierApp :: default ( ) ;
91
87
myapp. try_load_autctcfg ( ) ;
92
88
let myapplock = Arc :: new ( RwLock :: new ( myapp) ) ;
89
+ // make a copy of the app lock for the
90
+ // monitoring thread:
93
91
let shared_myapplock = Arc :: clone ( & myapplock) ;
94
92
95
93
thread:: spawn ( move || {
@@ -99,28 +97,19 @@ async fn main() -> eframe::Result {
99
97
let lockres = shared_myapplock. try_read ( ) ;
100
98
if !lockres. is_err ( ) {
101
99
let app_for_reading = lockres. unwrap ( ) ;
102
- // println-s here for now to sanity check the monitoring echo RPC
103
- // calls are behaving as expected:
104
100
if !app_for_reading. autctcfg . is_none ( ) {
105
- //println!("autctcfg was not none in the monitoring thread");
106
101
let rt = Runtime :: new ( ) . unwrap ( ) ;
107
102
let res = rt. block_on (
108
103
request_echo ( & app_for_reading. autctcfg . as_ref ( ) . unwrap ( ) ) ) ;
109
- //println!("Request echo method returned");
110
104
match res {
111
- Ok ( _) => { println ! ( "Echo successful" ) ;
105
+ Ok ( _) => { println ! ( "Echo successful; server is up. " ) ;
112
106
let mut state = app_for_reading
113
107
. server_state . lock ( ) . unwrap ( ) ;
114
108
* state = ServerState :: Ready ;
115
109
break ; } ,
116
- Err ( _) => {
117
- //println!("Echo call returned an error");
118
- }
110
+ Err ( _) => { }
119
111
} // end match
120
112
} // end autctcfg none check
121
- else {
122
- println ! ( "in monitoring thread, autctcfg was none" ) ;
123
- }
124
113
} // end check for lock
125
114
// Sleep for 1 second before the next check
126
115
thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
@@ -165,7 +154,6 @@ impl AutctVerifierApp {
165
154
|| CustomError ( "Failed to load signature message" . to_string ( ) ) ) ?) ;
166
155
}
167
156
cfg. bc_network = Some ( self . network . clone ( ) ) ;
168
- println ! ( "Finishing check cfg data ok" ) ;
169
157
Ok ( cfg)
170
158
}
171
159
@@ -184,8 +172,11 @@ impl AutctVerifierApp {
184
172
self . is_verif_loading = true ;
185
173
let result = Arc :: clone ( & self . verif_result ) ;
186
174
let cfgclone = self . autctcfg . clone ( ) . unwrap ( ) ;
187
- self . verif_runtime . spawn ( async move {
188
- let res = AutctVerifierApp :: verify ( cfgclone) . await ;
175
+ // logic here is as for `request_echo` above:
176
+ thread:: spawn ( move || {
177
+ let rt = Runtime :: new ( ) . unwrap ( ) ;
178
+ let res = rt. block_on (
179
+ AutctVerifierApp :: verify ( cfgclone) ) ;
189
180
* result. lock ( ) . unwrap ( ) = Some ( res) ;
190
181
} ) ;
191
182
}
@@ -227,7 +218,6 @@ impl AutctVerifierApp {
227
218
dot_pos : & Pos2 , dot_radius : f32 ) {
228
219
// Determine the color of the dot based on the verification
229
220
// server(called in the background)'s state:
230
- //println!("Got into update dot");
231
221
let process_state = * self . server_state . lock ( ) . unwrap ( ) ;
232
222
let dot_color = match process_state {
233
223
ServerState :: NotStarted => Color32 :: BLUE ,
@@ -249,7 +239,6 @@ impl AutctVerifierApp {
249
239
250
240
// Handle click on the circle
251
241
if response. clicked ( ) && process_state == ServerState :: NotStarted {
252
- println ! ( "Circle clicked! Starting the process..." ) ;
253
242
self . start_server ( ) ;
254
243
}
255
244
} ) ;
@@ -270,7 +259,6 @@ impl Default for AutctVerifierApp {
270
259
is_verif_loading : false ,
271
260
verif_result : Arc :: new ( Mutex :: new ( None ) ) ,
272
261
last_verif_result : None ,
273
- verif_runtime : Arc :: new ( Runtime :: new ( ) . unwrap ( ) ) ,
274
262
server_state : Arc :: new ( Mutex :: new ( ServerState :: NotStarted ) ) ,
275
263
autct_process_guard : None ,
276
264
}
@@ -280,7 +268,7 @@ impl Default for AutctVerifierApp {
280
268
impl eframe:: App for Wrapper {
281
269
fn update ( & mut self , ctx : & egui:: Context , _frame : & mut eframe:: Frame ) {
282
270
// Point of discussion: I think dark mode will work
283
- // a little better than light:
271
+ // a little better than light for most users :
284
272
//ctx.set_visuals(egui::Visuals::light());
285
273
286
274
// GUI does not respond to updates unless
@@ -306,7 +294,8 @@ impl eframe::App for Wrapper {
306
294
. min_height ( available_height * 0.25 )
307
295
. show ( ctx, |ui| {
308
296
ui. set_enabled ( !(
309
- state. show_verif_modal || state. show_conn_modal || state. show_verifres_modal ) ) ;
297
+ state. show_verif_modal || state. show_conn_modal ||
298
+ state. show_verifres_modal ) ) ;
310
299
if ui. add_sized ( [ 200.0 , 60.0 ] ,
311
300
egui:: Button :: new ( RichText :: new (
312
301
"VERIFY" ) . size ( 30.0 ) . strong ( ) ) ) . clicked ( ) {
@@ -396,7 +385,6 @@ impl eframe::App for Wrapper {
396
385
} ) ;
397
386
egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
398
387
egui:: ScrollArea :: vertical ( ) . show ( ui, |ui| {
399
- //println!("Starting the central panel paint");
400
388
ui. set_enabled ( !( state. show_verif_modal || state. show_conn_modal || state. show_verifres_modal ) ) ;
401
389
ui. label ( RichText :: new (
402
390
"Choose keyset (.pks) file:" ) . size ( 28.0 ) . strong ( ) ) ;
0 commit comments