core/consensus,node/runtime: Declare and implement authorities endpoint (#3207)

The goal of the commit is to be able to retrieve the current set of
authorities without needing to know the concrete consensus mechanism in
place.

In order to achieve the above this commit introduces the
`core/consensus/common/primitives` crate, declaring the `ConsensusApi`
runtime API. In addition it implements the above mentioned trait
definition in `node/runtime` by returning the current authorities of the
BABE consensus mechanism.
This commit is contained in:
Max Inden
2019-07-29 14:39:47 +02:00
committed by DemiMarie-parity
parent 9388f48942
commit cf80af9255
5 changed files with 71 additions and 0 deletions
+6
View File
@@ -538,4 +538,10 @@ impl_runtime_apis! {
}
}
}
impl consensus_primitives::ConsensusApi<Block, babe_primitives::AuthorityId> for Runtime {
fn authorities() -> Vec<babe_primitives::AuthorityId> {
Babe::authorities().into_iter().map(|(a, _)| a).collect()
}
}
}