@@ -261,23 +261,22 @@ impl Task {
261
261
// processing its actions continues unhindered.
262
262
async fn go ( mut self ) -> Result < ( ) > {
263
263
let mut pending = None ;
264
- let mut pending_dkgs = VecDeque :: new ( ) ;
264
+ let mut dkg_bundles = VecDeque :: new ( ) ;
265
265
let mut candidates = Candidates :: new ( ) ;
266
266
267
267
if !self . sailfish . is_init ( ) {
268
268
let actions = self . sailfish . init ( ) ;
269
269
candidates = self . execute ( actions) . await ?;
270
+ }
270
271
271
- // DKG dealing generation
272
- // TODO: move/copy to main loop when resharing
273
- if let Some ( bundle) = self . decrypter . gen_dkg_bundle ( ) {
274
- self . bundles . add_bundles ( once ( BundleVariant :: Dkg ( bundle) ) ) ;
275
- }
272
+ // TODO: move/copy to main loop when resharing
273
+ if let Some ( bundle) = self . decrypter . gen_dkg_bundle ( ) {
274
+ self . bundles . add_bundles ( once ( BundleVariant :: Dkg ( bundle) ) ) ;
276
275
}
277
276
278
277
loop {
279
278
if pending. is_none ( ) {
280
- while let Some ( ilist) = self . next_inclusion ( & mut candidates, & mut pending_dkgs ) {
279
+ while let Some ( ilist) = self . next_inclusion ( & mut candidates, & mut dkg_bundles ) {
281
280
if !self . decrypter . has_capacity ( ) {
282
281
pending = Some ( ilist) ;
283
282
break ;
@@ -288,12 +287,15 @@ impl Task {
288
287
}
289
288
}
290
289
291
- // always sync DKG bundles
292
- self . next_dkg ( & mut candidates, & mut pending_dkgs) ;
293
- if !pending_dkgs. is_empty ( ) {
294
- tracing:: debug!( num_bundles = %pending_dkgs. len( ) , "enqueuing dkg bundles" ) ;
295
- if let Err ( err) = self . decrypter . enqueue_dkg ( & mut pending_dkgs) . await {
296
- error ! ( node = %self . label, %err, "dkg enqueue error" ) ;
290
+ if pending. is_none ( ) {
291
+ while let Some ( dkg) = dkg_bundles. pop_front ( ) {
292
+ if !self . decrypter . has_capacity ( ) {
293
+ dkg_bundles. push_front ( dkg) ;
294
+ break ;
295
+ }
296
+ if let Err ( err) = self . decrypter . enqueue_dkg ( dkg) . await {
297
+ error ! ( node = %self . label, %err, "dkg enqueue error" ) ;
298
+ }
297
299
}
298
300
}
299
301
@@ -435,7 +437,7 @@ impl Task {
435
437
// preprocess the candidate list to pull out the DKG bundles first
436
438
for cl in lists. iter ( ) {
437
439
if let Some ( dkg) = cl. dkg_bundle ( ) {
438
- pending_dkgs. push_back ( dkg) ;
440
+ pending_dkgs. push_back ( dkg. clone ( ) ) ;
439
441
}
440
442
}
441
443
// then process it to construct the next inclusion list
@@ -456,19 +458,6 @@ impl Task {
456
458
}
457
459
None
458
460
}
459
-
460
- /// Handle candidate lists and "pull" out the DKG bundles, it won't touch or drop or consume
461
- /// regular/priority bundles, but only consume/take the DKG bundles inside `candidates` then
462
- /// append them to `pending_dkgs`.
463
- fn next_dkg ( & mut self , candidates : & mut Candidates , pending_dkgs : & mut VecDeque < DkgBundle > ) {
464
- for ( _, _, list) in candidates. iter_mut ( ) {
465
- for cl in list. iter_mut ( ) {
466
- if let Some ( dkg) = cl. take_dkg_bundle ( ) {
467
- pending_dkgs. push_back ( dkg) ;
468
- }
469
- }
470
- }
471
- }
472
461
}
473
462
474
463
#[ derive( Debug , thiserror:: Error ) ]
0 commit comments