-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5e540d
commit 8a6bd6b
Showing
8 changed files
with
576 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "generate-bags" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
creditcoin-node-runtime = { path = "../" } | ||
generate-bags = { workspace = true } | ||
clap = { version = "4.4.6", features = ["derive"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
use generate_bags::generate_thresholds; | ||
|
||
#[derive(Parser)] | ||
struct Cli { | ||
/// Total issuance of the currency in millions | ||
#[clap(short, long)] | ||
total_issuance: u128, | ||
|
||
/// Minimum account balance | ||
#[clap(short, long, default_value_t = 8456776)] | ||
minimum_balance: u128, | ||
|
||
#[clap(long, default_value_t = 200)] | ||
n_bags: usize, | ||
|
||
#[clap(long)] | ||
output: PathBuf, | ||
} | ||
|
||
/* | ||
pub struct U128CurrencyToVote; | ||
impl U128CurrencyToVote { | ||
fn factor(issuance: u128) -> u128 { | ||
(issuance / u64::MAX as u128).max(1) | ||
} | ||
} | ||
impl CurrencyToVote<u128> for U128CurrencyToVote { | ||
fn to_vote(value: u128, issuance: u128) -> u64 { | ||
(value / Self::factor(issuance)).saturated_into() | ||
} | ||
fn to_currency(value: u128, issuance: u128) -> u128 { | ||
value.saturating_mul(Self::factor(issuance)) | ||
} | ||
} */ | ||
|
||
fn main() -> Result<(), std::io::Error> { | ||
let Cli { total_issuance, minimum_balance, n_bags, output } = Cli::parse(); | ||
|
||
let issuance_ctc = total_issuance * creditcoin_node_runtime::CTC * 1_000_000; | ||
|
||
println!("Issuance ctc = {issuance_ctc}; factor = {}", (issuance_ctc / u64::MAX as u128)); | ||
|
||
generate_thresholds::<creditcoin_node_runtime::Runtime>( | ||
n_bags, | ||
&output, | ||
issuance_ctc, | ||
minimum_balance, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.