Clean up Validator::new()
This commit is contained in:
parent
81ba18eea6
commit
e218f4e56e
|
@ -127,7 +127,6 @@ pub struct Validator {
|
|||
}
|
||||
|
||||
impl Validator {
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub fn new(
|
||||
mut node: Node,
|
||||
keypair: &Arc<Keypair>,
|
||||
|
@ -312,23 +311,28 @@ impl Validator {
|
|||
.set_entrypoint(entrypoint_info.clone());
|
||||
}
|
||||
|
||||
if config.wait_for_supermajority {
|
||||
info!(
|
||||
"Waiting for more than 75% of activated stake at slot {} to be in gossip...",
|
||||
bank.slot()
|
||||
wait_for_supermajority(config, &bank, &cluster_info);
|
||||
|
||||
let voting_keypair = if config.voting_disabled {
|
||||
None
|
||||
} else {
|
||||
Some(voting_keypair.clone())
|
||||
};
|
||||
|
||||
let poh_service = PohService::new(poh_recorder.clone(), &poh_config, &exit);
|
||||
assert_eq!(
|
||||
blockstore.new_shreds_signals.len(),
|
||||
1,
|
||||
"New shred signal for the TVU should be the same as the clear bank signal."
|
||||
);
|
||||
loop {
|
||||
let gossip_stake_percent = get_stake_percent_in_gossip(&bank, &cluster_info);
|
||||
|
||||
info!("{}% of activated stake in gossip", gossip_stake_percent,);
|
||||
if gossip_stake_percent > 75 {
|
||||
break;
|
||||
}
|
||||
sleep(Duration::new(1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
let sockets = Sockets {
|
||||
let tvu = Tvu::new(
|
||||
vote_account,
|
||||
voting_keypair,
|
||||
storage_keypair,
|
||||
&bank_forks,
|
||||
&cluster_info,
|
||||
Sockets {
|
||||
repair: node
|
||||
.sockets
|
||||
.repair
|
||||
|
@ -352,28 +356,7 @@ impl Validator {
|
|||
.iter()
|
||||
.map(|s| s.try_clone().expect("Failed to clone TVU forwards Sockets"))
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let voting_keypair = if config.voting_disabled {
|
||||
None
|
||||
} else {
|
||||
Some(voting_keypair.clone())
|
||||
};
|
||||
|
||||
let poh_service = PohService::new(poh_recorder.clone(), &poh_config, &exit);
|
||||
assert_eq!(
|
||||
blockstore.new_shreds_signals.len(),
|
||||
1,
|
||||
"New shred signal for the TVU should be the same as the clear bank signal."
|
||||
);
|
||||
|
||||
let tvu = Tvu::new(
|
||||
vote_account,
|
||||
voting_keypair,
|
||||
storage_keypair,
|
||||
&bank_forks,
|
||||
&cluster_info,
|
||||
sockets,
|
||||
},
|
||||
blockstore.clone(),
|
||||
&storage_state,
|
||||
config.blockstream_unix_socket.as_ref(),
|
||||
|
@ -567,6 +550,30 @@ fn new_banks_from_blockstore(
|
|||
)
|
||||
}
|
||||
|
||||
fn wait_for_supermajority(
|
||||
config: &ValidatorConfig,
|
||||
bank: &Arc<Bank>,
|
||||
cluster_info: &Arc<RwLock<ClusterInfo>>,
|
||||
) {
|
||||
if !config.wait_for_supermajority {
|
||||
return;
|
||||
}
|
||||
|
||||
info!(
|
||||
"Waiting for more than 75% of activated stake at slot {} to be in gossip...",
|
||||
bank.slot()
|
||||
);
|
||||
loop {
|
||||
let gossip_stake_percent = get_stake_percent_in_gossip(&bank, &cluster_info);
|
||||
|
||||
info!("{}% of activated stake in gossip", gossip_stake_percent,);
|
||||
if gossip_stake_percent > 75 {
|
||||
break;
|
||||
}
|
||||
sleep(Duration::new(1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_validator_for_tests() -> (Validator, ContactInfo, Keypair, PathBuf) {
|
||||
use crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo};
|
||||
|
||||
|
|
Loading…
Reference in New Issue