diff --git a/substrate/frame/aura/src/lib.rs b/substrate/frame/aura/src/lib.rs index d124ef0017..ca3d1f15f4 100644 --- a/substrate/frame/aura/src/lib.rs +++ b/substrate/frame/aura/src/lib.rs @@ -162,6 +162,27 @@ impl FindAuthor for Module { } } +/// We can not implement `FindAuthor` twice, because the compiler does not know if +/// `u32 == T::AuthorityId` and thus, prevents us to implement the trait twice. +#[doc(hidden)] +pub struct FindAccountFromAuthorIndex(sp_std::marker::PhantomData<(T, Inner)>); + +impl> FindAuthor + for FindAccountFromAuthorIndex +{ + fn find_author<'a, I>(digests: I) -> Option + where I: 'a + IntoIterator + { + let i = Inner::find_author(digests)?; + + let validators = >::authorities(); + validators.get(i as usize).map(|k| k.clone()) + } +} + +/// Find the authority ID of the Aura authority who authored the current block. +pub type AuraAuthorId = FindAccountFromAuthorIndex>; + impl IsMember for Module { fn is_member(authority_id: &T::AuthorityId) -> bool { Self::authorities()