Add storage mining pool to genesis and implement automatic reward redeeming (#4683)

* Add storage mining pool to genesis and implement automatic reward collection

* Address review comments
This commit is contained in:
Sagar Dhawan
2019-06-13 22:30:51 -07:00
committed by GitHub
parent ee68b9800e
commit 119467df59
9 changed files with 134 additions and 20 deletions

View File

@ -151,6 +151,22 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.required(true)
.help("Path to file containing the bootstrap leader's storage keypair"),
)
.arg(
Arg::with_name("storage_mining_pool_keypair_file")
.long("storage-mining-pool-keypair")
.value_name("KEYPAIR")
.takes_value(true)
.required(true)
.help("Path to file containing the storage mining pool storage keypair"),
)
.arg(
Arg::with_name("storage_mining_pool_lamports")
.long("storage-mining-pool-lamports")
.value_name("LAMPORTS")
.takes_value(true)
.required(true)
.help("Number of lamports to assign to the storage mining pool"),
)
.arg(
Arg::with_name("bootstrap_leader_lamports")
.long("bootstrap-leader-lamports")
@ -251,17 +267,22 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let bootstrap_stake_keypair_file = matches.value_of("bootstrap_stake_keypair_file").unwrap();
let bootstrap_storage_keypair_file =
matches.value_of("bootstrap_storage_keypair_file").unwrap();
let storage_mining_pool_keypair = matches
.value_of("storage_mining_pool_keypair_file")
.unwrap();
let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap();
let ledger_path = matches.value_of("ledger_path").unwrap();
let lamports = value_t_or_exit!(matches, "lamports", u64);
let bootstrap_leader_lamports = value_t_or_exit!(matches, "bootstrap_leader_lamports", u64);
let bootstrap_leader_stake_lamports =
value_t_or_exit!(matches, "bootstrap_leader_stake_lamports", u64);
let storage_pool_lamports = value_t_or_exit!(matches, "storage_mining_pool_lamports", u64);
let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?;
let bootstrap_vote_keypair = read_keypair(bootstrap_vote_keypair_file)?;
let bootstrap_stake_keypair = read_keypair(bootstrap_stake_keypair_file)?;
let bootstrap_storage_keypair = read_keypair(bootstrap_storage_keypair_file)?;
let storage_mining_keypair = read_keypair(storage_mining_pool_keypair)?;
let mint_keypair = read_keypair(mint_keypair_file)?;
let (vote_account, vote_state) = vote_state::create_bootstrap_leader_account(
@ -301,6 +322,10 @@ fn main() -> Result<(), Box<dyn error::Error>> {
1,
),
),
(
storage_mining_keypair.pubkey(),
storage_contract::create_mining_pool_account(storage_pool_lamports),
),
],
&[
solana_bpf_loader_program!(),