@@ -26,6 +26,7 @@ use hyle_modules::{
2626 modules:: Module , utils:: static_type_map:: Pick ,
2727} ;
2828use hyle_net:: { logged_task:: logged_task, ordered_join_set:: OrderedJoinSet } ;
29+ use indexmap:: IndexSet ;
2930use metrics:: MempoolMetrics ;
3031use serde:: { Deserialize , Serialize } ;
3132use staking:: state:: Staking ;
@@ -107,7 +108,11 @@ pub struct MempoolStore {
107108 waiting_dissemination_txs : BorshableIndexMap < TxHash , Transaction > ,
108109 #[ borsh( skip) ]
109110 own_data_proposal_in_preparation : JoinSet < ( DataProposalHash , DataProposal ) > ,
110- buffered_proposals : BTreeMap < LaneId , Vec < DataProposal > > ,
111+ // Skipped to clear on reset
112+ #[ borsh( skip) ]
113+ buffered_proposals : BTreeMap < LaneId , IndexSet < DataProposal > > , // This is an indexSet just so we can pop by idx.
114+ // Skipped to clear on reset
115+ #[ borsh( skip) ]
111116 buffered_podas : BTreeMap < LaneId , BTreeMap < DataProposalHash , Vec < UnaggregatedPoDA > > > ,
112117
113118 // verify_tx.rs
@@ -680,17 +685,19 @@ impl Mempool {
680685 self . lanes
681686 . put_no_verification ( lane_id. clone ( ) , ( metadata, data_proposal) ) ?;
682687
683- let mut waiting_proposals = match self . buffered_proposals . get_mut ( lane_id) {
688+ // Retry all buffered proposals in this lane.
689+ // We'll re-buffer them in the on_data_proposal logic if they fail to be processed.
690+ let waiting_proposals = match self . buffered_proposals . get_mut ( lane_id) {
684691 Some ( waiting_proposals) => std:: mem:: take ( waiting_proposals) ,
685- None => vec ! [ ] ,
692+ None => Default :: default ( ) ,
686693 } ;
687694
688695 // TODO: retry remaining wp when one succeeds to be processed
689- for wp in waiting_proposals. iter_mut ( ) {
696+ for wp in waiting_proposals. into_iter ( ) {
690697 if self . lanes . contains ( lane_id, & wp. hashed ( ) ) {
691698 continue ;
692699 }
693- self . on_data_proposal ( lane_id, wp. hashed ( ) , std :: mem :: take ( wp ) )
700+ self . on_data_proposal ( lane_id, wp. hashed ( ) , wp )
694701 . context ( "Consuming waiting data proposal" ) ?;
695702 }
696703
0 commit comments