reduce replicode, introduce passive staking support (#4207)

This commit is contained in:
Rob Walker
2019-05-07 22:22:43 -07:00
committed by GitHub
parent 7609a007c6
commit b49f8c0984
11 changed files with 96 additions and 86 deletions

View File

@ -1,46 +1,12 @@
use solana_sdk::account::Account;
pub use solana_runtime::genesis_utils::{
create_genesis_block_with_leader, BOOTSTRAP_LEADER_LAMPORTS,
};
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_program;
use solana_vote_api::vote_state;
use solana_sdk::signature::Keypair;
// The default stake placed with the bootstrap leader
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 42;
pub fn create_genesis_block_with_leader(
mint_lamports: u64,
leader_id: &Pubkey,
leader_stake_lamports: u64,
) -> (GenesisBlock, Keypair, Keypair) {
let mint_keypair = Keypair::new();
let voting_keypair = Keypair::new();
let genesis_block = GenesisBlock::new(
&leader_id,
&[
(
mint_keypair.pubkey(),
Account::new(mint_lamports, 0, &system_program::id()),
),
(
voting_keypair.pubkey(),
vote_state::create_bootstrap_leader_account(
&voting_keypair.pubkey(),
&leader_id,
0,
leader_stake_lamports,
),
),
],
&[],
);
(genesis_block, mint_keypair, voting_keypair)
}
// same as genesis_block::create_genesis_block, but with leader staking logic specific
// to this crate
// same as genesis_block::create_genesis_block, but with bootstrap_leader staking logic
// for the core crate tests
pub fn create_genesis_block(mint_lamports: u64) -> (GenesisBlock, Keypair) {
let (genesis_block, mint_keypair, _vote_keypair) = create_genesis_block_with_leader(
mint_lamports,