Account for all tokens at genesis (bp #7350) (#7358)

automerge
This commit is contained in:
mergify[bot]
2019-12-08 09:07:39 -08:00
committed by Grimes
parent 729e1159aa
commit 293ad196f3
5 changed files with 280 additions and 494 deletions

19
scripts/Cargo.toml Normal file
View File

@ -0,0 +1,19 @@
[package]
authors = ["Solana Maintainers <maintainers@solana.com>"]
edition = "2018"
name = "solana-scripts"
description = "Blockchain, Rebuilt for Scale"
version = "0.22.0"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
publish = false
[dependencies]
csv = "1.1"
serde = { version = "1.0.103", features = ["derive"] }
[[bin]]
name = "solana-csv-to-validator-infos"
path = "src/csv_to_validator_infos.rs"

View File

@ -0,0 +1,42 @@
// Utility to print ValidatorInfo structs for `genesis_accounts.rs`
//
// Usage:
// cargo run --bin solana-csv-to-validator-infos < validators.csv
use serde::Deserialize;
use std::error::Error;
use std::io;
use std::process;
#[derive(Debug, Deserialize)]
struct ValidatorRecord {
id: u64,
tokens: f64,
adjective: String,
noun: String,
identity_pubkey: String,
vote_pubkey: String,
}
fn parse_csv() -> Result<(), Box<dyn Error>> {
let mut rdr = csv::Reader::from_reader(io::stdin());
for result in rdr.deserialize() {
let record: ValidatorRecord = result?;
println!(
r#"ValidatorInfo {{name: "{adjective} {noun}", node: "{identity_pubkey}", node_sol: {tokens:.1}, vote: "{vote_pubkey}", commission: 0}},"#,
tokens = &record.tokens,
adjective = &record.adjective,
noun = &record.noun,
identity_pubkey = &record.identity_pubkey,
vote_pubkey = &record.vote_pubkey,
);
}
Ok(())
}
fn main() {
if let Err(err) = parse_csv() {
println!("error: {}", err);
process::exit(1);
}
}