mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-11 12:55:46 +00:00
use clap3 instead of structopt (#10632)
* use clap3 instead of structopt Signed-off-by: koushiro <koushiro.cqx@gmail.com> * format Signed-off-by: koushiro <koushiro.cqx@gmail.com> * update ss58-registry and revert some nits Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Fix clippy and doc Signed-off-by: koushiro <koushiro.cqx@gmail.com> * update clap to 3.0.7 Signed-off-by: koushiro <koushiro.cqx@gmail.com> * Apply review suggestions Signed-off-by: koushiro <koushiro.cqx@gmail.com> * remove useless option long name Signed-off-by: koushiro <koushiro.cqx@gmail.com> * cargo fmt Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
@@ -68,7 +68,7 @@ pub fn generate_random_npos_inputs(
|
||||
|
||||
// always generate a sensible desired number of candidates: elections are uninteresting if we
|
||||
// desire 0 candidates, or a number of candidates >= the actual number of candidates present
|
||||
let rounds = rng.gen_range(1, candidate_count);
|
||||
let rounds = rng.gen_range(1..candidate_count);
|
||||
|
||||
// candidates are easy: just a completely random set of IDs
|
||||
let mut candidates: Vec<AccountId> = Vec::with_capacity(candidate_count);
|
||||
@@ -95,7 +95,7 @@ pub fn generate_random_npos_inputs(
|
||||
let vote_weight = rng.gen();
|
||||
|
||||
// it's not interesting if a voter chooses 0 or all candidates, so rule those cases out.
|
||||
let n_candidates_chosen = rng.gen_range(1, candidates.len());
|
||||
let n_candidates_chosen = rng.gen_range(1..candidates.len());
|
||||
|
||||
let mut chosen_candidates = Vec::with_capacity(n_candidates_chosen);
|
||||
chosen_candidates.extend(candidates.choose_multiple(&mut rng, n_candidates_chosen));
|
||||
@@ -132,25 +132,25 @@ pub fn generate_random_npos_result(
|
||||
|
||||
(1..=target_count).for_each(|acc| {
|
||||
candidates.push(acc);
|
||||
let stake_var = rng.gen_range(ed, 100 * ed);
|
||||
let stake_var = rng.gen_range(ed..100 * ed);
|
||||
stake_of.insert(acc, base_stake + stake_var);
|
||||
});
|
||||
|
||||
let mut voters = Vec::with_capacity(voter_count as usize);
|
||||
(prefix..=(prefix + voter_count)).for_each(|acc| {
|
||||
let edge_per_this_voter = rng.gen_range(1, candidates.len());
|
||||
let edge_per_this_voter = rng.gen_range(1..candidates.len());
|
||||
// all possible targets
|
||||
let mut all_targets = candidates.clone();
|
||||
// we remove and pop into `targets` `edge_per_this_voter` times.
|
||||
let targets = (0..edge_per_this_voter)
|
||||
.map(|_| {
|
||||
let upper = all_targets.len() - 1;
|
||||
let idx = rng.gen_range(0, upper);
|
||||
let idx = rng.gen_range(0..upper);
|
||||
all_targets.remove(idx)
|
||||
})
|
||||
.collect::<Vec<AccountId>>();
|
||||
|
||||
let stake_var = rng.gen_range(ed, 100 * ed);
|
||||
let stake_var = rng.gen_range(ed..100 * ed);
|
||||
let stake = base_stake + stake_var;
|
||||
stake_of.insert(acc, stake);
|
||||
voters.push((acc, stake, targets));
|
||||
|
||||
Reference in New Issue
Block a user