2019-09-08 17:53:34 -07:00
|
|
|
use solana_client::thin_client::ThinClient;
|
|
|
|
use solana_core::contact_info::ContactInfo;
|
2019-12-03 16:31:59 -08:00
|
|
|
use solana_core::validator::Validator;
|
2019-09-08 17:53:34 -07:00
|
|
|
use solana_core::validator::ValidatorConfig;
|
|
|
|
use solana_sdk::pubkey::Pubkey;
|
|
|
|
use solana_sdk::signature::Keypair;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
pub struct ValidatorInfo {
|
|
|
|
pub keypair: Arc<Keypair>,
|
|
|
|
pub voting_keypair: Arc<Keypair>,
|
|
|
|
pub ledger_path: PathBuf,
|
|
|
|
pub contact_info: ContactInfo,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ClusterValidatorInfo {
|
|
|
|
pub info: ValidatorInfo,
|
|
|
|
pub config: ValidatorConfig,
|
2019-12-03 16:31:59 -08:00
|
|
|
pub validator: Option<Validator>,
|
2019-09-08 17:53:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ClusterValidatorInfo {
|
2019-12-03 16:31:59 -08:00
|
|
|
pub fn new(
|
|
|
|
validator_info: ValidatorInfo,
|
|
|
|
config: ValidatorConfig,
|
|
|
|
validator: Validator,
|
|
|
|
) -> Self {
|
2019-09-08 17:53:34 -07:00
|
|
|
Self {
|
|
|
|
info: validator_info,
|
|
|
|
config,
|
2019-12-03 16:31:59 -08:00
|
|
|
validator: Some(validator),
|
2019-09-08 17:53:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Cluster {
|
|
|
|
fn get_node_pubkeys(&self) -> Vec<Pubkey>;
|
|
|
|
fn get_validator_client(&self, pubkey: &Pubkey) -> Option<ThinClient>;
|
2020-01-30 21:51:11 -08:00
|
|
|
fn get_contact_info(&self, pubkey: &Pubkey) -> Option<&ContactInfo>;
|
2019-09-08 17:53:34 -07:00
|
|
|
fn exit_node(&mut self, pubkey: &Pubkey) -> ClusterValidatorInfo;
|
|
|
|
fn restart_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
|
2020-11-12 06:29:04 -08:00
|
|
|
fn create_restart_context(
|
|
|
|
&mut self,
|
|
|
|
pubkey: &Pubkey,
|
|
|
|
cluster_validator_info: &mut ClusterValidatorInfo,
|
|
|
|
) -> (solana_core::cluster_info::Node, Option<ContactInfo>);
|
|
|
|
fn restart_node_with_context(
|
|
|
|
cluster_validator_info: ClusterValidatorInfo,
|
|
|
|
restart_context: (solana_core::cluster_info::Node, Option<ContactInfo>),
|
|
|
|
) -> ClusterValidatorInfo;
|
|
|
|
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
|
2019-09-08 17:53:34 -07:00
|
|
|
fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig);
|
|
|
|
}
|