Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename fixes
  • Loading branch information
gavofyork committed Apr 1, 2019
commit acb2746385e312abfcb7cd106fd612173bd34a8f
6 changes: 3 additions & 3 deletions srml/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ fn authorities_change_logged() {
#[test]
fn partial_authorities_change_logged() {
with_externalities(&mut new_test_ext(vec![1, 2, 3]), || {
System::initialise(&2, &Default::default(), &Default::default());
System::initialize(&2, &Default::default(), &Default::default());
Consensus::set_authorities(&[UintAuthorityId(2), UintAuthorityId(4), UintAuthorityId(5)]);
Consensus::on_finalise(2);
let header = System::finalise();
Consensus::on_finalize(2);
let header = System::finalize();
assert_eq!(header.digest, testing::Digest {
logs: vec![
generic::DigestItem::AuthoritiesChange(
Expand Down
18 changes: 9 additions & 9 deletions srml/staking/src/phragmen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ pub struct Edge<AccountId> {
/// Returns an Option of elected candidates, if election is performed.
/// Returns None if not enough candidates exist.
pub fn elect<T: Trait + 'static, FR, FN, FV, FS>(
get_rounds: FR,
get_validators: FV,
get_nominators: FN,
stash_of: FS,
minimum_validator_count: usize,
config: ElectionConfig<BalanceOf<T>>,
get_rounds: FR,
get_validators: FV,
get_nominators: FN,
stash_of: FS,
minimum_validator_count: usize,
config: ElectionConfig<BalanceOf<T>>,
) -> Option<Vec<Candidate<T::AccountId, BalanceOf<T>>>> where
FR: Fn() -> usize,
FV: Fn() -> Box<dyn Iterator<
Expand All @@ -109,7 +109,7 @@ pub fn elect<T: Trait + 'static, FR, FN, FV, FS>(
>>,
for <'r> FS: Fn(&'r T::AccountId) -> BalanceOf<T>,
{
let expand = |b: BalanceOf<T>| <T::CurrencyToVote as Convert<BalanceOf<T>, u64>>::convert(b) as ExtendedBalance;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @kianenigma : No extraneous whitespace within code.

let expand = |b: BalanceOf<T>| <T::CurrencyToVote as Convert<BalanceOf<T>, u64>>::convert(b) as ExtendedBalance;
let shrink = |b: ExtendedBalance| <T::CurrencyToVote as Convert<ExtendedBalance, BalanceOf<T>>>::convert(b);
let rounds = get_rounds();
let mut elected_candidates;
Expand Down Expand Up @@ -164,7 +164,7 @@ pub fn elect<T: Trait + 'static, FR, FN, FV, FS>(
.collect::<Vec<Candidate<T::AccountId, BalanceOf<T>>>>();

// 4- If we have more candidates then needed, run Phragmén.
if candidates.len() >= rounds {
if candidates.len() > rounds {
elected_candidates = Vec::with_capacity(rounds);
// Main election loop
for _round in 0..rounds {
Expand Down Expand Up @@ -254,7 +254,7 @@ pub fn elect<T: Trait + 'static, FR, FN, FV, FS>(
}
}
} else {
if candidates.len() > minimum_validator_count {
if candidates.len() >= minimum_validator_count {
// if we don't have enough candidates, just choose all that have some vote.
elected_candidates = candidates;
for n in &mut nominators {
Expand Down