@@ -6,6 +6,8 @@ use indexmap::IndexMap;
66use tycho_types:: models:: { BlockId , IndexedValidatorDescription } ;
77use tycho_util:: FastHasherState ;
88
9+ use crate :: PeerIdInner ;
10+
911// TODO: Decide how to be with this collator-defined type
1012#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
1113pub struct ValidationSessionId {
@@ -61,12 +63,9 @@ impl ValidatorEvents {
6163 self . listener
6264 . on_session_started ( session_id, first_mc_seqno, own_validator_idx, validators) ;
6365
64- let mut remap = IndexMap :: < u16 , u16 , FastHasherState > :: with_capacity_and_hasher (
65- validators. len ( ) ,
66- Default :: default ( ) ,
67- ) ;
66+ let mut remap = IndexMap :: with_capacity_and_hasher ( validators. len ( ) , Default :: default ( ) ) ;
6867 for ( i, validator) in validators. iter ( ) . enumerate ( ) {
69- remap. insert ( validator. validator_idx , i as u16 ) ;
68+ remap. insert ( validator. desc . public_key . 0 , i as u16 ) ;
7069 }
7170
7271 ValidatorSessionScope {
@@ -81,7 +80,7 @@ impl ValidatorEvents {
8180pub struct ValidatorSessionScope {
8281 recorder : Arc < dyn ValidatorEventsListener > ,
8382 session_id : ValidationSessionId ,
84- remap_ids : Arc < IndexMap < u16 , u16 , FastHasherState > > ,
83+ remap_ids : Arc < IndexMap < PeerIdInner , u16 , FastHasherState > > ,
8584 is_sealed : AtomicBool ,
8685}
8786
@@ -120,7 +119,7 @@ impl Drop for ValidatorSessionScope {
120119pub struct BlockValidationScope {
121120 recorder : Arc < dyn ValidatorEventsListener > ,
122121 session_id : ValidationSessionId ,
123- remap_ids : Arc < IndexMap < u16 , u16 , FastHasherState > > ,
122+ remap_ids : Arc < IndexMap < PeerIdInner , u16 , FastHasherState > > ,
124123 block_id : BlockId ,
125124 signature_slots : Box < [ AtomicU8 ] > ,
126125 is_sealed : AtomicBool ,
@@ -135,14 +134,14 @@ impl BlockValidationScope {
135134 & self . block_id
136135 }
137136
138- pub fn receive_signature ( & self , validator_idx : u16 , is_valid : bool ) -> bool {
137+ pub fn receive_signature ( & self , peer_id : & PeerIdInner , is_valid : bool ) -> bool {
139138 let mask = if is_valid {
140139 ReceivedSignature :: VALID_SIGNATURE_BIT
141140 } else {
142141 ReceivedSignature :: INVALID_SIGNATURE_BIT
143142 } ;
144143
145- let Some ( slot_id) = self . remap_ids . get ( & validator_idx ) else {
144+ let Some ( slot_id) = self . remap_ids . get ( peer_id ) else {
146145 return false ;
147146 } ;
148147
0 commit comments