mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 14:28:37 +00:00
Directory Restructure (#1163)
* Move tests -> testing * Directory restructure * Update Cargo.toml during restructure * Update Makefile during restructure * Fix arbitrary path
This commit is contained in:
54
common/eth2_config/src/lib.rs
Normal file
54
common/eth2_config/src/lib.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use types::ChainSpec;
|
||||
|
||||
/// The core configuration of a Lighthouse beacon node.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct Eth2Config {
|
||||
pub spec_constants: String,
|
||||
pub spec: ChainSpec,
|
||||
}
|
||||
|
||||
impl Default for Eth2Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
spec_constants: "minimal".to_string(),
|
||||
spec: ChainSpec::minimal(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Eth2Config {
|
||||
pub fn mainnet() -> Self {
|
||||
Self {
|
||||
spec_constants: "mainnet".to_string(),
|
||||
spec: ChainSpec::mainnet(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minimal() -> Self {
|
||||
Self {
|
||||
spec_constants: "minimal".to_string(),
|
||||
spec: ChainSpec::minimal(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn interop() -> Self {
|
||||
Self {
|
||||
spec_constants: "interop".to_string(),
|
||||
spec: ChainSpec::interop(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use toml;
|
||||
|
||||
#[test]
|
||||
fn serde_serialize() {
|
||||
let _ =
|
||||
toml::to_string(&Eth2Config::default()).expect("Should serde encode default config");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user