Skip to content

Commit

Permalink
EE-1020: bring code in line with current CL practices
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser999 authored and marc-casperlabs committed May 21, 2020
1 parent aa8b295 commit 0c726e6
Show file tree
Hide file tree
Showing 16 changed files with 521 additions and 467 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[package]
name = "casper-node"
version = "0.1.0"
authors = ["Marc Brinkmann <[email protected]>",
"Fraser Hutchison <[email protected]>"]
authors = ["Marc Brinkmann <[email protected]>", "Fraser Hutchison <[email protected]>"]
edition = "2018"
description = "The CasperLabs blockchain node server"
description = "The CasperLabs blockchain node"
publish = false # Prevent accidental `cargo publish` for now.
license-file = "LICENSE"

[dependencies]
anyhow = "1.0.28"
async-trait = "0.1.31"
displaydoc = "0.1.6"
either = "1.5.3"
enum-iterator = "0.6.0"
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# CasperLabs node
# casper-node

The is the core application for the CasperLabs blockchain.

## Building

To compile this application, simply run `cargo build` on a recent stable Rust (`>= 1.43.1`) version.
This is the core application for the CasperLabs blockchain.

## Running a validator node

Launching a validator node with the default configuration is done by simply launching the application:
To run a validator node with the default configuration:

```
casper-node validator
cargo run --release -- validator
```

It is very likely that the configuration requires editing though, so typically one will want to generate a configuration file first, edit it and then launch:

```
casper-node generate-config > mynode.toml
cargo run --release -- generate-config > mynode.toml
# ... edit mynode.toml
casper-node validator -c mynode.toml
cargo run --release -- validator --config=mynode.toml
```

## Development
Expand All @@ -30,4 +26,4 @@ A good starting point is to build the documentation and read it in your browser:
cargo doc --no-deps --open
```

When generating a configuration file, it is usually helpful to set the log-level to `DEBUG` during development.
When generating a configuration file, it is usually helpful to set the log-level to `DEBUG` during development.
Binary file added images/CasperLabs_Logo_Favicon_RGB_50px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/CasperLabs_Logo_Symbol_RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 20 additions & 12 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
//! Command-line option parsing.
//!
//! Most configuration is done through the configuration, which is the only required command-line
//! argument. However some configuration values can be overwritten for convenience's sake.
use std::{io, io::Write, path};
//! Most configuration is done via config files (see [`config`](../config/index.html) for details).
use std::{io, io::Write, path::PathBuf};

use anyhow::bail;
use structopt::StructOpt;
use tracing::Level;

use crate::{config, reactor, tls};
use crate::{
config,
reactor::{self, validator::Reactor},
tls,
};

// Note: The docstring on `Cli` is the help shown when calling the binary with `--help`.
#[derive(Debug, StructOpt)]
/// CasperLabs blockchain node.
pub enum Cli {
/// Generate a self-signed node certificate
/// Generate a self-signed node certificate.
GenerateCert {
/// Output path base the certificate, private key pair in PEM format. The cert will be stored as `output.crt.pem`, while the key will be stored as `output.key.pem`.
output: path::PathBuf,
/// Output path base of the certificate. The certificate will be stored as
/// `output.crt.pem`, while the key will be stored as `output.key.pem`.
output: PathBuf,
},
/// Generate a configuration file from defaults and dump it to stdout.
GenerateConfig {},
Expand All @@ -26,7 +34,7 @@ pub enum Cli {
Validator {
#[structopt(short, long, env)]
/// Path to configuration file.
config: Option<path::PathBuf>,
config: Option<PathBuf>,

/// Override log-level, forcing debug output.
#[structopt(short, long)]
Expand All @@ -35,12 +43,12 @@ pub enum Cli {
}

impl Cli {
/// Execute selected CLI command.
/// Executes selected CLI command.
pub async fn run(self) -> anyhow::Result<()> {
match self {
Cli::GenerateCert { output } => {
if output.file_name().is_none() {
anyhow::bail!("not a valid output path");
bail!("not a valid output path");
}

let mut cert_path = output.clone();
Expand Down Expand Up @@ -69,11 +77,11 @@ impl Cli {
.transpose()?
.unwrap_or_default();
if debug {
cfg.log.level = tracing::Level::DEBUG;
cfg.log.level = Level::DEBUG;
}
cfg.log.setup_logging()?;

reactor::launch::<reactor::validator::Reactor>(cfg).await
reactor::launch::<Reactor>(cfg).await
}
}
}
Expand Down
Loading

0 comments on commit 0c726e6

Please sign in to comment.