remove weighting and staking dependency in BABE (#3412)

* remove weighting and staking dependency in BABE

* bump spec version

* Update Cargo.toml

* Update lock

* Fix warnings.
This commit is contained in:
Robert Habermeier
2019-08-15 21:21:14 +02:00
committed by Gavin Wood
parent 6bc72cea62
commit ee0ac798eb
4 changed files with 7 additions and 15 deletions
+6 -11
View File
@@ -25,7 +25,7 @@ use rstd::{result, prelude::*};
use srml_support::{decl_storage, decl_module, StorageValue, StorageMap, traits::FindAuthor, traits::Get};
use timestamp::{OnTimestampSet};
use sr_primitives::{generic::DigestItem, ConsensusEngineId};
use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert};
use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon};
#[cfg(feature = "std")]
use timestamp::TimestampInherentData;
use codec::{Encode, Decode};
@@ -298,16 +298,11 @@ impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> {
fn on_timestamp_set(_moment: T::Moment) { }
}
impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = AuthorityId;
fn on_new_session<'a, I: 'a>(_changed: bool, validators: I, queued_validators: I)
where I: Iterator<Item=(&'a T::AccountId, AuthorityId)>
{
use staking::BalanceOf;
let to_votes = |b: BalanceOf<T>| {
<T::CurrencyToVote as Convert<BalanceOf<T>, u64>>::convert(b)
};
// Update epoch index
let epoch_index = EpochIndex::get()
.checked_add(1)
@@ -316,8 +311,8 @@ impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Mod
EpochIndex::put(epoch_index);
// Update authorities.
let authorities = validators.map(|(account, k)| {
(k, to_votes(staking::Module::<T>::stakers(account).total))
let authorities = validators.map(|(_account, k)| {
(k, 1)
}).collect::<Vec<_>>();
Authorities::put(authorities);
@@ -349,8 +344,8 @@ impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Mod
// After we update the current epoch, we signal the *next* epoch change
// so that nodes can track changes.
let next_authorities = queued_validators.map(|(account, k)| {
(k, to_votes(staking::Module::<T>::stakers(account).total))
let next_authorities = queued_validators.map(|(_account, k)| {
(k, 1)
}).collect::<Vec<_>>();
let next_epoch_start_slot = EpochStartSlot::get().saturating_add(T::EpochDuration::get());