@@ -541,6 +541,24 @@ where
541541	) 
542542} 
543543
544+ /// A descriptor for an authority set hard fork. These are authority set changes 
545+ /// that are not signalled by the runtime and instead are defined off-chain 
546+ /// (hence the hard fork). 
547+ pub  struct  AuthoritySetHardFork < Block :  BlockT >  { 
548+ 	/// The new authority set id. 
549+  	pub  set_id :  SetId , 
550+ 	/// The block hash and number at which the hard fork should be applied. 
551+  	pub  block :  ( Block :: Hash ,  NumberFor < Block > ) , 
552+ 	/// The authorities in the new set. 
553+  	pub  authorities :  AuthorityList , 
554+ 	/// The latest block number that was finalized before this authority set 
555+  	/// hard fork. When defined, the authority set change will be forced, i.e. 
556+  	/// the node won't wait for the block above to be finalized before enacting 
557+  	/// the change, and the given finalized number will be used as a base for 
558+  	/// voting. 
559+  	pub  last_finalized :  Option < NumberFor < Block > > , 
560+ } 
561+ 
544562/// Make block importer and link half necessary to tie the background voter to 
545563/// it. A vector of authority set hard forks can be passed, any authority set 
546564/// change signaled at the given block (either already signalled or in a further 
@@ -550,7 +568,7 @@ pub fn block_import_with_authority_set_hard_forks<BE, Block: BlockT, Client, SC>
550568	client :  Arc < Client > , 
551569	genesis_authorities_provider :  & dyn  GenesisAuthoritySetProvider < Block > , 
552570	select_chain :  SC , 
553- 	authority_set_hard_forks :  Vec < ( SetId ,   ( Block :: Hash ,   NumberFor < Block > ) ,   AuthorityList ) > , 
571+ 	authority_set_hard_forks :  Vec < AuthoritySetHardFork < Block > > , 
554572	telemetry :  Option < TelemetryHandle > , 
555573)  -> Result < ( GrandpaBlockImport < BE ,  Block ,  Client ,  SC > ,  LinkHalf < Block ,  Client ,  SC > ) ,  ClientError > 
556574where 
@@ -580,19 +598,24 @@ where
580598
581599	let  ( justification_sender,  justification_stream)  = GrandpaJustificationStream :: channel ( ) ; 
582600
583- 	// create pending change objects with 0 delay and enacted on finality 
584- 	// (i.e. standard changes) for each authority set hard fork. 
601+ 	// create pending change objects with 0 delay for each authority set hard fork. 
585602	let  authority_set_hard_forks = authority_set_hard_forks
586603		. into_iter ( ) 
587- 		. map ( |( set_id,  ( hash,  number) ,  authorities) | { 
604+ 		. map ( |fork| { 
605+ 			let  delay_kind = if  let  Some ( last_finalized)  = fork. last_finalized  { 
606+ 				authorities:: DelayKind :: Best  {  median_last_finalized :  last_finalized } 
607+ 			}  else  { 
608+ 				authorities:: DelayKind :: Finalized 
609+ 			} ; 
610+ 
588611			( 
589- 				set_id, 
612+ 				fork . set_id , 
590613				authorities:: PendingChange  { 
591- 					next_authorities :  authorities, 
614+ 					next_authorities :  fork . authorities , 
592615					delay :  Zero :: zero ( ) , 
593- 					canon_hash :  hash , 
594- 					canon_height :  number , 
595- 					delay_kind :  authorities :: DelayKind :: Finalized , 
616+ 					canon_hash :  fork . block . 0 , 
617+ 					canon_height :  fork . block . 1 , 
618+ 					delay_kind, 
596619				} , 
597620			) 
598621		} ) 
0 commit comments