File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,27 @@ impl<T: Trait> FindAuthor<u32> for Module<T> {
162
162
}
163
163
}
164
164
165
+ /// We can not implement `FindAuthor` twice, because the compiler does not know if
166
+ /// `u32 == T::AuthorityId` and thus, prevents us to implement the trait twice.
167
+ #[ doc( hidden) ]
168
+ pub struct FindAccountFromAuthorIndex < T , Inner > ( sp_std:: marker:: PhantomData < ( T , Inner ) > ) ;
169
+
170
+ impl < T : Trait , Inner : FindAuthor < u32 > > FindAuthor < T :: AuthorityId >
171
+ for FindAccountFromAuthorIndex < T , Inner >
172
+ {
173
+ fn find_author < ' a , I > ( digests : I ) -> Option < T :: AuthorityId >
174
+ where I : ' a + IntoIterator < Item =( ConsensusEngineId , & ' a [ u8 ] ) >
175
+ {
176
+ let i = Inner :: find_author ( digests) ?;
177
+
178
+ let validators = <Module < T > >:: authorities ( ) ;
179
+ validators. get ( i as usize ) . map ( |k| k. clone ( ) )
180
+ }
181
+ }
182
+
183
+ /// Find the authority ID of the Aura authority who authored the current block.
184
+ pub type AuraAuthorId < T > = FindAccountFromAuthorIndex < T , Module < T > > ;
185
+
165
186
impl < T : Trait > IsMember < T :: AuthorityId > for Module < T > {
166
187
fn is_member ( authority_id : & T :: AuthorityId ) -> bool {
167
188
Self :: authorities ( )
You can’t perform that action at this time.
0 commit comments