9a68702d4d
* revamping mixnode connfig * wip * native client config revamping * wip * building socks5 * using const for mixnnode config template * compiling updated gateway * nym-api * nym-sdk * everything compiling once more but definitely not compatible with CI and older versions (yet) * creating full directory structure on init * renamed paths to storage_paths and fixed mixnode template * mixnode config migration * gateway config migration * nym-api config migration * native client config migration * socks5 client config migration * NR config migration * removed deprecations (that will be resolved in the following PRs) + fixed clippy * nym-connect clippy * nym-connect config updates * outfox fixes * defined socks5 lib config * clippy * fixed wasm client build * removed explicit packet_type argument when starting base client it's known implicitly from the previously passed config struct * Empty commit * fixed re-using gateway information when client configs are re-initialised * fixed borrowing id value in nym-connect * post-rebase fixes * updated 'old_config' versions --------- Co-authored-by: Tommy Verrall <tommy@nymtech.net>
86 lines
2.1 KiB
Rust
86 lines
2.1 KiB
Rust
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#[macro_use]
|
|
extern crate rocket;
|
|
|
|
use ::nym_config::defaults::setup_env;
|
|
use clap::{crate_name, crate_version, Parser};
|
|
use lazy_static::lazy_static;
|
|
use nym_bin_common::build_information::BinaryBuildInformation;
|
|
#[allow(unused_imports)]
|
|
use nym_bin_common::logging::{maybe_print_banner, setup_logging};
|
|
#[cfg(feature = "cpucycles")]
|
|
use nym_bin_common::setup_tracing;
|
|
#[cfg(feature = "cpucycles")]
|
|
use nym_mixnode_common::measure;
|
|
#[cfg(feature = "cpucycles")]
|
|
use tracing::instrument;
|
|
mod commands;
|
|
mod config;
|
|
mod node;
|
|
|
|
lazy_static! {
|
|
pub static ref PRETTY_BUILD_INFORMATION: String =
|
|
BinaryBuildInformation::new(env!("CARGO_PKG_VERSION")).pretty_print();
|
|
}
|
|
|
|
// Helper for passing LONG_VERSION to clap
|
|
fn pretty_build_info_static() -> &'static str {
|
|
&PRETTY_BUILD_INFORMATION
|
|
}
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author = "Nymtech", version, about, long_version = pretty_build_info_static())]
|
|
struct Cli {
|
|
/// Path pointing to an env file that configures the mixnode.
|
|
#[clap(short, long)]
|
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
|
|
|
#[clap(subcommand)]
|
|
command: commands::Commands,
|
|
}
|
|
|
|
#[cfg(feature = "cpucycles")]
|
|
#[instrument(fields(cpucycles))]
|
|
fn test_function() {
|
|
measure!({})
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> anyhow::Result<()> {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature = "cpucycles")] {
|
|
setup_tracing!("mixnode");
|
|
info!("CPU cycles measurement is ON")
|
|
} else {
|
|
setup_logging();
|
|
info!("CPU cycles measurement is OFF")
|
|
}
|
|
}
|
|
|
|
maybe_print_banner(crate_name!(), crate_version!());
|
|
|
|
let args = Cli::parse();
|
|
setup_env(args.config_env_file.as_ref());
|
|
commands::execute(args).await?;
|
|
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature = "cpucycles")] {
|
|
opentelemetry::global::shutdown_tracer_provider();
|
|
}}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use clap::CommandFactory;
|
|
|
|
#[test]
|
|
fn verify_cli() {
|
|
Cli::command().debug_assert();
|
|
}
|
|
}
|