use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use tendermint::chain;
use tendermint_config::net;
use tendermint_p2p::secret_connection;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ValidatorConfig {
pub addr: net::Address,
pub chain_id: chain::Id,
#[serde(default = "reconnect_default")]
pub reconnect: bool,
pub timeout: Option<u16>,
pub secret_key: Option<PathBuf>,
pub max_height: Option<tendermint::block::Height>,
pub protocol_version: ProtocolVersion,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
pub enum ProtocolVersion {
#[serde(rename = "v0.34")]
V0_34,
#[serde(rename = "v0.33")]
V0_33,
}
impl From<ProtocolVersion> for secret_connection::Version {
fn from(version: ProtocolVersion) -> secret_connection::Version {
match version {
ProtocolVersion::V0_34 => secret_connection::Version::V0_34,
ProtocolVersion::V0_33 => secret_connection::Version::V0_33,
}
}
}
fn reconnect_default() -> bool {
true
}