Skip to content

Commit

Permalink
config: rename ValidatorConfig to NodeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 23, 2022
1 parent 7965618 commit 3d6caa1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::{
use sui_types::{base_types::encode_bytes_hex, crypto::get_key_pair_from_rng};

use crate::{
genesis, new_network_address, CommitteeConfig, ConsensuseConfig, GenesisConfig, NetworkConfig,
ValidatorConfig, ValidatorGenesisInfo, ValidatorInfo, AUTHORITIES_DB_NAME, CONSENSUS_DB_NAME,
genesis, new_network_address, CommitteeConfig, ConsensusConfig, GenesisConfig, NetworkConfig,
NodeConfig, ValidatorGenesisInfo, ValidatorInfo, AUTHORITIES_DB_NAME, CONSENSUS_DB_NAME,
DEFAULT_STAKE,
};

Expand Down Expand Up @@ -183,15 +183,15 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
.config_directory
.join(CONSENSUS_DB_NAME)
.join(encode_bytes_hex(public_key));
let consensus_config = ConsensuseConfig {
let consensus_config = ConsensusConfig {
consensus_address,
consensus_db_path,
narwhal_config: Default::default(),
};

let metrics_address = new_network_address();

ValidatorConfig {
NodeConfig {
key_pair: validator.key_pair,
db_path,
network_address,
Expand Down
30 changes: 15 additions & 15 deletions crates/sui-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ pub mod utils;
const DEFAULT_STAKE: usize = 1;

#[derive(Debug, Deserialize, Serialize)]
pub struct ValidatorConfig {
key_pair: KeyPair,
db_path: PathBuf,
network_address: Multiaddr,
metrics_address: Multiaddr,
pub struct NodeConfig {
pub key_pair: KeyPair,
pub db_path: PathBuf,
pub network_address: Multiaddr,
pub metrics_address: Multiaddr,

pub consensus_config: ConsensuseConfig,
committee_config: CommitteeConfig,
pub consensus_config: ConsensusConfig,
pub committee_config: CommitteeConfig,

genesis: genesis::Genesis,
}

impl Config for ValidatorConfig {}
impl Config for NodeConfig {}

impl ValidatorConfig {
impl NodeConfig {
pub fn key_pair(&self) -> &KeyPair {
&self.key_pair
}
Expand All @@ -64,7 +64,7 @@ impl ValidatorConfig {
&self.network_address
}

pub fn consensus_config(&self) -> &ConsensuseConfig {
pub fn consensus_config(&self) -> &ConsensusConfig {
&self.consensus_config
}

Expand All @@ -78,7 +78,7 @@ impl ValidatorConfig {
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ConsensuseConfig {
pub struct ConsensusConfig {
consensus_address: Multiaddr,
consensus_db_path: PathBuf,

Expand All @@ -88,7 +88,7 @@ pub struct ConsensuseConfig {
pub narwhal_config: DebugIgnore<ConsensusParameters>,
}

impl ConsensuseConfig {
impl ConsensusConfig {
pub fn address(&self) -> &Multiaddr {
&self.consensus_address
}
Expand Down Expand Up @@ -164,7 +164,7 @@ impl ValidatorInfo {
/// all validators
#[derive(Debug, Deserialize, Serialize)]
pub struct NetworkConfig {
pub validator_configs: Vec<ValidatorConfig>,
pub validator_configs: Vec<NodeConfig>,
loaded_move_packages: Vec<(PathBuf, ObjectID)>,
genesis: genesis::Genesis,
pub account_keys: Vec<KeyPair>,
Expand All @@ -173,7 +173,7 @@ pub struct NetworkConfig {
impl Config for NetworkConfig {}

impl NetworkConfig {
pub fn validator_configs(&self) -> &[ValidatorConfig] {
pub fn validator_configs(&self) -> &[NodeConfig] {
&self.validator_configs
}

Expand All @@ -195,7 +195,7 @@ impl NetworkConfig {
self.validator_configs()[0].committee_config().committee()
}

pub fn into_validator_configs(self) -> Vec<ValidatorConfig> {
pub fn into_validator_configs(self) -> Vec<NodeConfig> {
self.validator_configs
}

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use sui_config::ValidatorConfig;
use sui_config::NodeConfig;
use sui_core::authority_server::AuthorityServerHandle;
use tracing::info;

Expand All @@ -11,7 +11,7 @@ pub struct SuiNode {
}

impl SuiNode {
pub async fn start(config: &ValidatorConfig) -> Result<()> {
pub async fn start(config: &NodeConfig) -> Result<()> {
let server = sui_core::make::make_server(config).await?.spawn().await?;

info!(node =? config.public_key(),
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Result;
use clap::Parser;
use multiaddr::Multiaddr;
use std::path::PathBuf;
use sui_config::{PersistedConfig, ValidatorConfig};
use sui_config::{NodeConfig, PersistedConfig};
use tracing::info;

const PROM_PORT_ADDR: &str = "0.0.0.0:9184";
Expand Down Expand Up @@ -34,7 +34,7 @@ async fn main() -> Result<()> {

let args = Args::parse();

let mut config = PersistedConfig::<ValidatorConfig>::read(&args.config_path)?;
let mut config = PersistedConfig::<NodeConfig>::read(&args.config_path)?;

// TODO: Switch from prometheus exporter. See https://github.com/MystenLabs/sui/issues/1907
let prom_binding = PROM_PORT_ADDR.parse().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions sui_core/src/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use sui_config::NetworkConfig;
use sui_config::ValidatorConfig;
use sui_config::NodeConfig;
use tokio::sync::mpsc::channel;
use tracing::{error, info};

Expand Down Expand Up @@ -71,7 +71,7 @@ impl SuiNetwork {
}
}

pub async fn make_server(validator_config: &ValidatorConfig) -> Result<AuthorityServer> {
pub async fn make_server(validator_config: &NodeConfig) -> Result<AuthorityServer> {
let mut store_path = PathBuf::from(validator_config.db_path());
store_path.push("store");
let store = Arc::new(AuthorityStore::open(store_path, None));
Expand Down Expand Up @@ -105,7 +105,7 @@ pub async fn make_server(validator_config: &ValidatorConfig) -> Result<Authority
/// Spawn all the subsystems run by a Sui authority: a consensus node, a sui authority server,
/// and a consensus listener bridging the consensus node and the sui authority.
pub async fn make_authority(
validator_config: &ValidatorConfig,
validator_config: &NodeConfig,
state: AuthorityState,
) -> Result<AuthorityServer> {
let (tx_consensus_to_sui, rx_consensus_to_sui) = channel(1_000);
Expand Down

0 comments on commit 3d6caa1

Please sign in to comment.