From 2f003bf8aefaea329b8b94707679cd6b3569afe3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 13 Apr 2023 16:48:17 +0200 Subject: [PATCH] chore: move client constant to primitives (#2220) Co-authored-by: Roman Krasiuk --- crates/net/eth-wire/src/hello.rs | 7 ++----- crates/primitives/src/constants.rs | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/net/eth-wire/src/hello.rs b/crates/net/eth-wire/src/hello.rs index f550b0a6a4..4ab36b05f5 100644 --- a/crates/net/eth-wire/src/hello.rs +++ b/crates/net/eth-wire/src/hello.rs @@ -1,14 +1,11 @@ use crate::{capability::Capability, EthVersion, ProtocolVersion}; use reth_codecs::derive_arbitrary; -use reth_primitives::PeerId; +use reth_primitives::{constants::RETH_CLIENT_VERSION, PeerId}; use reth_rlp::{RlpDecodable, RlpEncodable}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -/// The client version: `reth/v{major}.{minor}.{patch}` -pub(crate) const DEFAULT_CLIENT_VERSION: &str = concat!("reth/v", env!("CARGO_PKG_VERSION")); - // TODO: determine if we should allow for the extra fields at the end like EIP-706 suggests /// Message used in the `p2p` handshake, containing information about the supported RLPx protocol /// version and capabilities. @@ -98,7 +95,7 @@ impl HelloMessageBuilder { let Self { protocol_version, client_version, capabilities, port, id } = self; HelloMessage { protocol_version: protocol_version.unwrap_or_default(), - client_version: client_version.unwrap_or_else(|| DEFAULT_CLIENT_VERSION.to_string()), + client_version: client_version.unwrap_or_else(|| RETH_CLIENT_VERSION.to_string()), capabilities: capabilities.unwrap_or_else(|| { vec![EthVersion::Eth68.into(), EthVersion::Eth67.into(), EthVersion::Eth66.into()] }), diff --git a/crates/primitives/src/constants.rs b/crates/primitives/src/constants.rs index 36547aba2b..a3bc30cd7a 100644 --- a/crates/primitives/src/constants.rs +++ b/crates/primitives/src/constants.rs @@ -4,6 +4,9 @@ use crate::{H256, U256}; use hex_literal::hex; use std::time::Duration; +/// The client version: `reth/v{major}.{minor}.{patch}` +pub const RETH_CLIENT_VERSION: &str = concat!("reth/v", env!("CARGO_PKG_VERSION")); + /// The first four bytes of the call data for a function call specifies the function to be called. pub const SELECTOR_LEN: usize = 4;