@@ -19,6 +19,7 @@ use itertools::Itertools;
19
19
use logging:: crit;
20
20
use logging:: TimeLatch ;
21
21
use slot_clock:: SlotClock ;
22
+ use std:: collections:: hash_map:: Entry ;
22
23
use std:: collections:: { HashMap , HashSet } ;
23
24
use std:: future:: Future ;
24
25
use std:: pin:: Pin ;
@@ -182,7 +183,10 @@ pub struct IgnoredRpcBlock {
182
183
/// A backfill batch work that has been queued for processing later.
183
184
pub struct QueuedBackfillBatch ( pub AsyncFn ) ;
184
185
185
- pub struct QueuedColumnReconstruction ( pub AsyncFn ) ;
186
+ pub struct QueuedColumnReconstruction {
187
+ pub block_root : Hash256 ,
188
+ pub process_fn : AsyncFn ,
189
+ }
186
190
187
191
impl < E : EthSpec > TryFrom < WorkEvent < E > > for QueuedBackfillBatch {
188
192
type Error = WorkEvent < E > ;
@@ -264,6 +268,8 @@ struct ReprocessQueue<S> {
264
268
queued_sampling_requests : FnvHashMap < usize , ( QueuedSamplingRequest , DelayKey ) > ,
265
269
/// Sampling requests per block root.
266
270
awaiting_sampling_requests_per_block_root : HashMap < Hash256 , Vec < QueuedSamplingRequestId > > ,
271
+ /// Column reconstruction per block root.
272
+ queued_column_reconstructions : HashMap < Hash256 , DelayKey > ,
267
273
/// Queued backfill batches
268
274
queued_backfill_batches : Vec < QueuedBackfillBatch > ,
269
275
@@ -441,6 +447,7 @@ impl<S: SlotClock> ReprocessQueue<S> {
441
447
awaiting_lc_updates_per_parent_root : HashMap :: new ( ) ,
442
448
awaiting_sampling_requests_per_block_root : <_ >:: default ( ) ,
443
449
queued_backfill_batches : Vec :: new ( ) ,
450
+ queued_column_reconstructions : HashMap :: new ( ) ,
444
451
next_attestation : 0 ,
445
452
next_lc_update : 0 ,
446
453
next_sampling_request_update : 0 ,
@@ -840,8 +847,19 @@ impl<S: SlotClock> ReprocessQueue<S> {
840
847
}
841
848
}
842
849
InboundEvent :: Msg ( DelayColumnReconstruction ( request) ) => {
843
- self . column_reconstructions_delay_queue
844
- . insert ( request, QUEUED_RECONSTRUCTION_DELAY ) ;
850
+ match self . queued_column_reconstructions . entry ( request. block_root ) {
851
+ Entry :: Occupied ( key) => {
852
+ // Push back the reattempted reconstruction
853
+ self . column_reconstructions_delay_queue
854
+ . reset ( key. get ( ) , QUEUED_RECONSTRUCTION_DELAY )
855
+ }
856
+ Entry :: Vacant ( vacant) => {
857
+ let delay_key = self
858
+ . column_reconstructions_delay_queue
859
+ . insert ( request, QUEUED_RECONSTRUCTION_DELAY ) ;
860
+ vacant. insert ( delay_key) ;
861
+ }
862
+ }
845
863
}
846
864
// A block that was queued for later processing is now ready to be processed.
847
865
InboundEvent :: ReadyGossipBlock ( ready_block) => {
@@ -967,6 +985,8 @@ impl<S: SlotClock> ReprocessQueue<S> {
967
985
}
968
986
}
969
987
InboundEvent :: ReadyColumnReconstruction ( column_reconstruction) => {
988
+ self . queued_column_reconstructions
989
+ . remove ( & column_reconstruction. block_root ) ;
970
990
if self
971
991
. ready_work_tx
972
992
. try_send ( ReadyWork :: ColumnReconstruction ( column_reconstruction) )
0 commit comments