Skip to content

Commit 312ae77

Browse files
committed
review fix
1 parent ad80377 commit 312ae77

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

catalyst-toolbox/src/bin/cli/stats/voters/active.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use catalyst_toolbox::stats::distribution::Stats;
22
use catalyst_toolbox::stats::voters::calculate_active_wallet_distribution;
3+
use color_eyre::Report;
34
use std::ops::Range;
45
use std::path::PathBuf;
56
use structopt::StructOpt;
@@ -26,7 +27,7 @@ pub enum Command {
2627
}
2728

2829
impl ActiveVotersCommand {
29-
pub fn exec(&self) -> Result<(), catalyst_toolbox::stats::Error> {
30+
pub fn exec(&self) -> Result<(), Report> {
3031
match self.command {
3132
Command::Count => calculate_active_wallet_distribution(
3233
Stats::new(self.threshold),

catalyst-toolbox/src/bin/cli/stats/voters/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod active;
22
mod initials;
33

44
use active::ActiveVotersCommand;
5+
use color_eyre::Report;
56
use initials::InitialVotersCommand;
67
use structopt::StructOpt;
78

@@ -12,7 +13,7 @@ pub enum VotersCommand {
1213
}
1314

1415
impl VotersCommand {
15-
pub fn exec(self) -> Result<(), catalyst_toolbox::stats::Error> {
16+
pub fn exec(self) -> Result<(), Report> {
1617
match self {
1718
Self::Initials(initials) => initials.exec(),
1819
Self::Active(active) => active.exec(),

catalyst-toolbox/src/stats/distribution.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn levels(threshold: u64) -> Vec<Range<u64>> {
55
vec![
66
(0..450),
77
(450..threshold),
8-
(500..1_000),
8+
(threshold..1_000),
99
(1_000..2_000),
1010
(2_000..5_000),
1111
(5_000..10_000),
@@ -98,7 +98,9 @@ impl Stats {
9898
}
9999

100100
fn format_big_number(n: u64) -> String {
101-
if n % 1_000_000_000 == 0 {
101+
if n == 0 {
102+
n.to_string()
103+
} else if n % 1_000_000_000 == 0 {
102104
format!("{} MLD", n / 1_000_000)
103105
} else if n % 1_00000 == 0 {
104106
format!("{} M", n / 1_000_000)

catalyst-toolbox/src/stats/voters.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use std::path::Path;
1313
fn blacklist_addresses(genesis: &Block0Configuration) -> Vec<Address> {
1414
let discrimination = genesis.blockchain_configuration.discrimination;
1515

16-
#[allow(clippy::needless_collect)]
1716
genesis
1817
.blockchain_configuration
1918
.committees
@@ -40,12 +39,13 @@ fn vote_counts_as_addresses(
4039
votes_count: VoteCount,
4140
genesis: &Block0Configuration,
4241
) -> Vec<(InitialUTxO, u32)> {
43-
votes_count
42+
genesis
43+
.initial
4444
.iter()
45-
.filter_map(|(address, votes_count)| {
46-
for initials in &genesis.initial {
47-
if let Initial::Fund(funds) = initials {
48-
if let Some(utxo) = funds.iter().find(|utxo| {
45+
.filter_map(|initials| {
46+
if let Initial::Fund(funds) = initials {
47+
for utxo in funds {
48+
if let Some((_, votes_count)) = votes_count.iter().find(|(address, _)| {
4949
account_hex_to_address(
5050
address.to_string(),
5151
genesis.blockchain_configuration.discrimination,

0 commit comments

Comments
 (0)