b5c8b69547
* Experiment with serde * Framed encoding serde POC * Outfox framing * Outfox rest compat (#3333) * Outfox forwarding compat * Tidy up interface * PacketSize compat * Address PR comments * Rebase on develop commit342883fcbeAuthor: durch <durch@users.noreply.github.com> Date: Thu Apr 27 09:17:18 2023 +0200 Put back PacketType 1 commit61a0ee5a19Author: Tommy Verrall <tommyvez@protonmail.com> Date: Wed Apr 26 16:37:29 2023 +0100 change output for cpu-cycle management logs commit3956109c7eAuthor: Tommy Verrall <tommy@nymtech.net> Date: Wed Apr 26 12:13:22 2023 +0100 change the workflow file to build with cpucycles commit8d725b13c5Author: durch <durch@users.noreply.github.com> Date: Mon Apr 24 13:14:58 2023 +0200 Outfox client compat commit4d166c389bAuthor: durch <durch@users.noreply.github.com> Date: Fri Apr 21 00:30:46 2023 +0200 Address PR comments commit145c3c1223Author: durch <durch@users.noreply.github.com> Date: Fri Apr 21 00:12:35 2023 +0200 Rename PacketMode commitcbd654d6fdAuthor: Drazen Urch <drazen@urch.eu> Date: Thu Apr 20 23:59:40 2023 +0200 Outfox rest compat (#3333) * Outfox forwarding compat * Tidy up interface * PacketSize compat commite7be91a94cAuthor: durch <durch@users.noreply.github.com> Date: Wed Apr 19 16:36:48 2023 +0200 Remove serde cruft commit582e7d566aAuthor: durch <durch@users.noreply.github.com> Date: Wed Apr 19 16:24:09 2023 +0200 Outfox framing commit6464da5f01Author: durch <durch@users.noreply.github.com> Date: Tue Apr 18 22:23:02 2023 +0200 Framing compat commitd5e77e499bAuthor: durch <durch@users.noreply.github.com> Date: Tue Apr 18 18:18:54 2023 +0200 Framed encoding serde POC commitf086f9c35aAuthor: durch <durch@users.noreply.github.com> Date: Tue Apr 18 16:54:21 2023 +0200 Experiment with serde * Client tweaks * Speed up from_plaintext * SurbAcks * More work on the reciever end, and outfox format * Cleanup and fmt * Wrap up rebase * Happy clippy * Fix lock files * Final cleanup
87 lines
2.3 KiB
Rust
87 lines
2.3 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() {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(feature = "cpucycles")] {
|
|
let home_dir = dirs::home_dir().expect("Could not get $HOME");
|
|
let logs_dir = home_dir.join(".nym").join("logs");
|
|
let logs_dir_str = logs_dir.to_str().expect("Could not construct logs path");
|
|
setup_tracing!(logs_dir_str);
|
|
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();
|
|
}}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use clap::CommandFactory;
|
|
|
|
#[test]
|
|
fn verify_cli() {
|
|
Cli::command().debug_assert();
|
|
}
|
|
}
|