From b6e8b3a08e88873d633956024879bdb575b48d00 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Mon, 9 Sep 2024 17:50:11 -0400 Subject: [PATCH] cuprated: version constants --- Cargo.lock | 27 +++++++++++++++++++++++++++ Cargo.toml | 1 + binaries/cuprated/Cargo.toml | 3 ++- binaries/cuprated/src/main.rs | 1 + binaries/cuprated/src/rpc/json.rs | 16 ++++++++++------ binaries/cuprated/src/version.rs | 8 ++++++++ 6 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 binaries/cuprated/src/version.rs diff --git a/Cargo.lock b/Cargo.lock index c941dc12..8ef6323d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -386,6 +386,26 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +[[package]] +name = "const_format" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -927,6 +947,7 @@ dependencies = [ "cfg-if", "chrono", "clap", + "const_format", "crossbeam", "crypto-bigint", "cuprate-address-book", @@ -3044,6 +3065,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" + [[package]] name = "untrusted" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index 2d718936..d2b3397a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ clap = { version = "4.4.7", default-features = false } chrono = { version = "0.4.31", default-features = false } crypto-bigint = { version = "0.5.5", default-features = false } crossbeam = { version = "0.8.4", default-features = false } +const_format = { version = "0.2.33", default-features = false } curve25519-dalek = { version = "4.1.3", default-features = false } dashmap = { version = "5.5.3", default-features = false } dirs = { version = "5.0.1", default-features = false } diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index a886c124..634a5220 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -42,10 +42,11 @@ borsh = { workspace = true } bytemuck = { workspace = true } bytes = { workspace = true } cfg-if = { workspace = true } -clap = { workspace = true } +clap = { workspace = true, features = ["cargo"] } chrono = { workspace = true } crypto-bigint = { workspace = true } crossbeam = { workspace = true } +const_format = { workspace = true } curve25519-dalek = { workspace = true } dashmap = { workspace = true } dirs = { workspace = true } diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 04392260..b7abf41d 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -17,6 +17,7 @@ mod config; mod p2p; mod rpc; mod txpool; +mod version; fn main() { todo!() diff --git a/binaries/cuprated/src/rpc/json.rs b/binaries/cuprated/src/rpc/json.rs index 6bc0f7de..fd8cb89b 100644 --- a/binaries/cuprated/src/rpc/json.rs +++ b/binaries/cuprated/src/rpc/json.rs @@ -32,12 +32,16 @@ use cuprate_rpc_types::{ SyncInfoResponse, }, misc::{BlockHeader, Status}, + CORE_RPC_VERSION, }; use cuprate_types::{blockchain::BlockchainReadRequest, Chain}; use crate::{ - rpc::{blockchain, helper}, - rpc::{CupratedRpcHandlerState, RESTRICTED_BLOCK_COUNT, RESTRICTED_BLOCK_HEADER_RANGE}, + rpc::{ + blockchain, helper, CupratedRpcHandlerState, RESTRICTED_BLOCK_COUNT, + RESTRICTED_BLOCK_HEADER_RANGE, + }, + version::CUPRATED_VERSION_IS_RELEASE, }; /// Map a [`JsonRpcRequest`] to the function that will lead to a [`JsonRpcResponse`]. @@ -440,14 +444,14 @@ async fn get_coinbase_tx_sum( /// async fn get_version( - state: CupratedRpcHandlerState, + mut state: CupratedRpcHandlerState, request: GetVersionRequest, ) -> Result { Ok(GetVersionResponse { base: ResponseBase::ok(), - version: todo!(), - release: todo!(), - current_height: todo!(), + version: CORE_RPC_VERSION, + release: CUPRATED_VERSION_IS_RELEASE, + current_height: helper::top_height(&mut state).await?.0, target_height: todo!(), hard_forks: todo!(), }) diff --git a/binaries/cuprated/src/version.rs b/binaries/cuprated/src/version.rs new file mode 100644 index 00000000..c04a5b77 --- /dev/null +++ b/binaries/cuprated/src/version.rs @@ -0,0 +1,8 @@ +//! - +//! - + +use const_format::formatcp; + +pub const CUPRATED_VERSION: &str = formatcp!("{}", clap::crate_version!()); +pub const CUPRATED_RELEASE_NAME: &str = "Fluorine Fermi"; +pub const CUPRATED_VERSION_IS_RELEASE: bool = !cfg!(debug_assertions);