wire: enable workspace lints (#291)
Some checks are pending
Audit / audit (push) Waiting to run
CI / fmt (push) Waiting to run
CI / typo (push) Waiting to run
CI / ci (macos-latest, stable, bash) (push) Waiting to run
CI / ci (ubuntu-latest, stable, bash) (push) Waiting to run
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Waiting to run
Deny / audit (push) Waiting to run
Doc / build (push) Waiting to run
Doc / deploy (push) Blocked by required conditions

* wire: enable workspace lints

* revert match arm formatting
This commit is contained in:
hinto-janai 2024-09-18 18:19:32 -04:00 committed by GitHub
parent a1267619ef
commit e3a918bca5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 138 additions and 135 deletions

View file

@ -15,7 +15,7 @@ cuprate-levin = { path = "../levin" }
cuprate-epee-encoding = { path = "../epee-encoding" } cuprate-epee-encoding = { path = "../epee-encoding" }
cuprate-fixed-bytes = { path = "../fixed-bytes" } cuprate-fixed-bytes = { path = "../fixed-bytes" }
cuprate-types = { path = "../../types", default-features = false, features = ["epee"] } cuprate-types = { path = "../../types", default-features = false, features = ["epee"] }
cuprate-helper = { path = "../../helper", default-features = false, features = ["cast"] } cuprate-helper = { path = "../../helper", default-features = false, features = ["map"] }
bitflags = { workspace = true, features = ["std"] } bitflags = { workspace = true, features = ["std"] }
bytes = { workspace = true, features = ["std"] } bytes = { workspace = true, features = ["std"] }
@ -24,3 +24,5 @@ thiserror = { workspace = true }
[dev-dependencies] [dev-dependencies]
hex = { workspace = true, features = ["std"]} hex = { workspace = true, features = ["std"]}
[lints]
workspace = true

View file

@ -51,38 +51,38 @@ impl EpeeObject for NetworkAddress {
} }
impl NetworkAddress { impl NetworkAddress {
pub fn get_zone(&self) -> NetZone { pub const fn get_zone(&self) -> NetZone {
match self { match self {
NetworkAddress::Clear(_) => NetZone::Public, Self::Clear(_) => NetZone::Public,
} }
} }
pub fn is_loopback(&self) -> bool { pub const fn is_loopback(&self) -> bool {
// TODO // TODO
false false
} }
pub fn is_local(&self) -> bool { pub const fn is_local(&self) -> bool {
// TODO // TODO
false false
} }
pub fn port(&self) -> u16 { pub const fn port(&self) -> u16 {
match self { match self {
NetworkAddress::Clear(ip) => ip.port(), Self::Clear(ip) => ip.port(),
} }
} }
} }
impl From<net::SocketAddrV4> for NetworkAddress { impl From<net::SocketAddrV4> for NetworkAddress {
fn from(value: net::SocketAddrV4) -> Self { fn from(value: net::SocketAddrV4) -> Self {
NetworkAddress::Clear(value.into()) Self::Clear(value.into())
} }
} }
impl From<net::SocketAddrV6> for NetworkAddress { impl From<net::SocketAddrV6> for NetworkAddress {
fn from(value: net::SocketAddrV6) -> Self { fn from(value: net::SocketAddrV6) -> Self {
NetworkAddress::Clear(value.into()) Self::Clear(value.into())
} }
} }

View file

@ -74,7 +74,7 @@ impl From<NetworkAddress> for TaggedNetworkAddress {
fn from(value: NetworkAddress) -> Self { fn from(value: NetworkAddress) -> Self {
match value { match value {
NetworkAddress::Clear(addr) => match addr { NetworkAddress::Clear(addr) => match addr {
SocketAddr::V4(addr) => TaggedNetworkAddress { SocketAddr::V4(addr) => Self {
ty: Some(1), ty: Some(1),
addr: Some(AllFieldsNetworkAddress { addr: Some(AllFieldsNetworkAddress {
m_ip: Some(u32::from_be_bytes(addr.ip().octets())), m_ip: Some(u32::from_be_bytes(addr.ip().octets())),
@ -82,7 +82,7 @@ impl From<NetworkAddress> for TaggedNetworkAddress {
addr: None, addr: None,
}), }),
}, },
SocketAddr::V6(addr) => TaggedNetworkAddress { SocketAddr::V6(addr) => Self {
ty: Some(2), ty: Some(2),
addr: Some(AllFieldsNetworkAddress { addr: Some(AllFieldsNetworkAddress {
addr: Some(addr.ip().octets()), addr: Some(addr.ip().octets()),

View file

@ -55,27 +55,27 @@ pub enum LevinCommand {
impl std::fmt::Display for LevinCommand { impl std::fmt::Display for LevinCommand {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if let LevinCommand::Unknown(id) = self { if let Self::Unknown(id) = self {
return f.write_str(&format!("unknown id: {}", id)); return f.write_str(&format!("unknown id: {id}"));
} }
f.write_str(match self { f.write_str(match self {
LevinCommand::Handshake => "handshake", Self::Handshake => "handshake",
LevinCommand::TimedSync => "timed sync", Self::TimedSync => "timed sync",
LevinCommand::Ping => "ping", Self::Ping => "ping",
LevinCommand::SupportFlags => "support flags", Self::SupportFlags => "support flags",
LevinCommand::NewBlock => "new block", Self::NewBlock => "new block",
LevinCommand::NewTransactions => "new transactions", Self::NewTransactions => "new transactions",
LevinCommand::GetObjectsRequest => "get objects request", Self::GetObjectsRequest => "get objects request",
LevinCommand::GetObjectsResponse => "get objects response", Self::GetObjectsResponse => "get objects response",
LevinCommand::ChainRequest => "chain request", Self::ChainRequest => "chain request",
LevinCommand::ChainResponse => "chain response", Self::ChainResponse => "chain response",
LevinCommand::NewFluffyBlock => "new fluffy block", Self::NewFluffyBlock => "new fluffy block",
LevinCommand::FluffyMissingTxsRequest => "fluffy missing transaction request", Self::FluffyMissingTxsRequest => "fluffy missing transaction request",
LevinCommand::GetTxPoolCompliment => "get transaction pool compliment", Self::GetTxPoolCompliment => "get transaction pool compliment",
LevinCommand::Unknown(_) => unreachable!(), Self::Unknown(_) => unreachable!(),
}) })
} }
} }
@ -83,50 +83,51 @@ impl std::fmt::Display for LevinCommand {
impl LevinCommandTrait for LevinCommand { impl LevinCommandTrait for LevinCommand {
fn bucket_size_limit(&self) -> u64 { fn bucket_size_limit(&self) -> u64 {
// https://github.com/monero-project/monero/blob/00fd416a99686f0956361d1cd0337fe56e58d4a7/src/cryptonote_basic/connection_context.cpp#L37 // https://github.com/monero-project/monero/blob/00fd416a99686f0956361d1cd0337fe56e58d4a7/src/cryptonote_basic/connection_context.cpp#L37
#[expect(clippy::match_same_arms, reason = "formatting is more clear")]
match self { match self {
LevinCommand::Handshake => 65536, Self::Handshake => 65536,
LevinCommand::TimedSync => 65536, Self::TimedSync => 65536,
LevinCommand::Ping => 4096, Self::Ping => 4096,
LevinCommand::SupportFlags => 4096, Self::SupportFlags => 4096,
LevinCommand::NewBlock => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though) Self::NewBlock => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though)
LevinCommand::NewTransactions => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though) Self::NewTransactions => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though)
LevinCommand::GetObjectsRequest => 1024 * 1024 * 2, // 2 MB Self::GetObjectsRequest => 1024 * 1024 * 2, // 2 MB
LevinCommand::GetObjectsResponse => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though) Self::GetObjectsResponse => 1024 * 1024 * 128, // 128 MB (max packet is a bit less than 100 MB though)
LevinCommand::ChainRequest => 512 * 1024, // 512 kB Self::ChainRequest => 512 * 1024, // 512 kB
LevinCommand::ChainResponse => 1024 * 1024 * 4, // 4 MB Self::ChainResponse => 1024 * 1024 * 4, // 4 MB
LevinCommand::NewFluffyBlock => 1024 * 1024 * 4, // 4 MB Self::NewFluffyBlock => 1024 * 1024 * 4, // 4 MB
LevinCommand::FluffyMissingTxsRequest => 1024 * 1024, // 1 MB Self::FluffyMissingTxsRequest => 1024 * 1024, // 1 MB
LevinCommand::GetTxPoolCompliment => 1024 * 1024 * 4, // 4 MB Self::GetTxPoolCompliment => 1024 * 1024 * 4, // 4 MB
LevinCommand::Unknown(_) => u64::MAX, Self::Unknown(_) => u64::MAX,
} }
} }
fn is_handshake(&self) -> bool { fn is_handshake(&self) -> bool {
matches!(self, LevinCommand::Handshake) matches!(self, Self::Handshake)
} }
} }
impl From<u32> for LevinCommand { impl From<u32> for LevinCommand {
fn from(value: u32) -> Self { fn from(value: u32) -> Self {
match value { match value {
1001 => LevinCommand::Handshake, 1001 => Self::Handshake,
1002 => LevinCommand::TimedSync, 1002 => Self::TimedSync,
1003 => LevinCommand::Ping, 1003 => Self::Ping,
1007 => LevinCommand::SupportFlags, 1007 => Self::SupportFlags,
2001 => LevinCommand::NewBlock, 2001 => Self::NewBlock,
2002 => LevinCommand::NewTransactions, 2002 => Self::NewTransactions,
2003 => LevinCommand::GetObjectsRequest, 2003 => Self::GetObjectsRequest,
2004 => LevinCommand::GetObjectsResponse, 2004 => Self::GetObjectsResponse,
2006 => LevinCommand::ChainRequest, 2006 => Self::ChainRequest,
2007 => LevinCommand::ChainResponse, 2007 => Self::ChainResponse,
2008 => LevinCommand::NewFluffyBlock, 2008 => Self::NewFluffyBlock,
2009 => LevinCommand::FluffyMissingTxsRequest, 2009 => Self::FluffyMissingTxsRequest,
2010 => LevinCommand::GetTxPoolCompliment, 2010 => Self::GetTxPoolCompliment,
x => LevinCommand::Unknown(x), x => Self::Unknown(x),
} }
} }
} }
@ -191,19 +192,19 @@ pub enum ProtocolMessage {
} }
impl ProtocolMessage { impl ProtocolMessage {
pub fn command(&self) -> LevinCommand { pub const fn command(&self) -> LevinCommand {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
ProtocolMessage::NewBlock(_) => C::NewBlock, Self::NewBlock(_) => C::NewBlock,
ProtocolMessage::NewFluffyBlock(_) => C::NewFluffyBlock, Self::NewFluffyBlock(_) => C::NewFluffyBlock,
ProtocolMessage::GetObjectsRequest(_) => C::GetObjectsRequest, Self::GetObjectsRequest(_) => C::GetObjectsRequest,
ProtocolMessage::GetObjectsResponse(_) => C::GetObjectsResponse, Self::GetObjectsResponse(_) => C::GetObjectsResponse,
ProtocolMessage::ChainRequest(_) => C::ChainRequest, Self::ChainRequest(_) => C::ChainRequest,
ProtocolMessage::ChainEntryResponse(_) => C::ChainResponse, Self::ChainEntryResponse(_) => C::ChainResponse,
ProtocolMessage::NewTransactions(_) => C::NewTransactions, Self::NewTransactions(_) => C::NewTransactions,
ProtocolMessage::FluffyMissingTransactionsRequest(_) => C::FluffyMissingTxsRequest, Self::FluffyMissingTransactionsRequest(_) => C::FluffyMissingTxsRequest,
ProtocolMessage::GetTxPoolCompliment(_) => C::GetTxPoolCompliment, Self::GetTxPoolCompliment(_) => C::GetTxPoolCompliment,
} }
} }
@ -230,26 +231,26 @@ impl ProtocolMessage {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
ProtocolMessage::NewBlock(val) => build_message(C::NewBlock, val, builder)?, Self::NewBlock(val) => build_message(C::NewBlock, val, builder)?,
ProtocolMessage::NewTransactions(val) => { Self::NewTransactions(val) => {
build_message(C::NewTransactions, val, builder)? build_message(C::NewTransactions, val, builder)?;
} }
ProtocolMessage::GetObjectsRequest(val) => { Self::GetObjectsRequest(val) => {
build_message(C::GetObjectsRequest, val, builder)? build_message(C::GetObjectsRequest, val, builder)?;
} }
ProtocolMessage::GetObjectsResponse(val) => { Self::GetObjectsResponse(val) => {
build_message(C::GetObjectsResponse, val, builder)? build_message(C::GetObjectsResponse, val, builder)?;
} }
ProtocolMessage::ChainRequest(val) => build_message(C::ChainRequest, val, builder)?, Self::ChainRequest(val) => build_message(C::ChainRequest, val, builder)?,
ProtocolMessage::ChainEntryResponse(val) => { Self::ChainEntryResponse(val) => {
build_message(C::ChainResponse, val, builder)? build_message(C::ChainResponse, val, builder)?;
} }
ProtocolMessage::NewFluffyBlock(val) => build_message(C::NewFluffyBlock, val, builder)?, Self::NewFluffyBlock(val) => build_message(C::NewFluffyBlock, val, builder)?,
ProtocolMessage::FluffyMissingTransactionsRequest(val) => { Self::FluffyMissingTransactionsRequest(val) => {
build_message(C::FluffyMissingTxsRequest, val, builder)? build_message(C::FluffyMissingTxsRequest, val, builder)?;
} }
ProtocolMessage::GetTxPoolCompliment(val) => { Self::GetTxPoolCompliment(val) => {
build_message(C::GetTxPoolCompliment, val, builder)? build_message(C::GetTxPoolCompliment, val, builder)?;
} }
} }
Ok(()) Ok(())
@ -265,14 +266,14 @@ pub enum AdminRequestMessage {
} }
impl AdminRequestMessage { impl AdminRequestMessage {
pub fn command(&self) -> LevinCommand { pub const fn command(&self) -> LevinCommand {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
AdminRequestMessage::Handshake(_) => C::Handshake, Self::Handshake(_) => C::Handshake,
AdminRequestMessage::Ping => C::Ping, Self::Ping => C::Ping,
AdminRequestMessage::SupportFlags => C::SupportFlags, Self::SupportFlags => C::SupportFlags,
AdminRequestMessage::TimedSync(_) => C::TimedSync, Self::TimedSync(_) => C::TimedSync,
} }
} }
@ -286,13 +287,13 @@ impl AdminRequestMessage {
cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf) cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf)
.map_err(|e| BucketError::BodyDecodingError(e.into()))?; .map_err(|e| BucketError::BodyDecodingError(e.into()))?;
AdminRequestMessage::Ping Self::Ping
} }
C::SupportFlags => { C::SupportFlags => {
cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf) cuprate_epee_encoding::from_bytes::<EmptyMessage, _>(buf)
.map_err(|e| BucketError::BodyDecodingError(e.into()))?; .map_err(|e| BucketError::BodyDecodingError(e.into()))?;
AdminRequestMessage::SupportFlags Self::SupportFlags
} }
_ => return Err(BucketError::UnknownCommand), _ => return Err(BucketError::UnknownCommand),
}) })
@ -302,11 +303,11 @@ impl AdminRequestMessage {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
AdminRequestMessage::Handshake(val) => build_message(C::Handshake, val, builder)?, Self::Handshake(val) => build_message(C::Handshake, val, builder)?,
AdminRequestMessage::TimedSync(val) => build_message(C::TimedSync, val, builder)?, Self::TimedSync(val) => build_message(C::TimedSync, val, builder)?,
AdminRequestMessage::Ping => build_message(C::Ping, EmptyMessage, builder)?, Self::Ping => build_message(C::Ping, EmptyMessage, builder)?,
AdminRequestMessage::SupportFlags => { Self::SupportFlags => {
build_message(C::SupportFlags, EmptyMessage, builder)? build_message(C::SupportFlags, EmptyMessage, builder)?;
} }
} }
Ok(()) Ok(())
@ -322,14 +323,14 @@ pub enum AdminResponseMessage {
} }
impl AdminResponseMessage { impl AdminResponseMessage {
pub fn command(&self) -> LevinCommand { pub const fn command(&self) -> LevinCommand {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
AdminResponseMessage::Handshake(_) => C::Handshake, Self::Handshake(_) => C::Handshake,
AdminResponseMessage::Ping(_) => C::Ping, Self::Ping(_) => C::Ping,
AdminResponseMessage::SupportFlags(_) => C::SupportFlags, Self::SupportFlags(_) => C::SupportFlags,
AdminResponseMessage::TimedSync(_) => C::TimedSync, Self::TimedSync(_) => C::TimedSync,
} }
} }
@ -349,11 +350,11 @@ impl AdminResponseMessage {
use LevinCommand as C; use LevinCommand as C;
match self { match self {
AdminResponseMessage::Handshake(val) => build_message(C::Handshake, val, builder)?, Self::Handshake(val) => build_message(C::Handshake, val, builder)?,
AdminResponseMessage::TimedSync(val) => build_message(C::TimedSync, val, builder)?, Self::TimedSync(val) => build_message(C::TimedSync, val, builder)?,
AdminResponseMessage::Ping(val) => build_message(C::Ping, val, builder)?, Self::Ping(val) => build_message(C::Ping, val, builder)?,
AdminResponseMessage::SupportFlags(val) => { Self::SupportFlags(val) => {
build_message(C::SupportFlags, val, builder)? build_message(C::SupportFlags, val, builder)?;
} }
} }
Ok(()) Ok(())
@ -368,23 +369,23 @@ pub enum Message {
} }
impl Message { impl Message {
pub fn is_request(&self) -> bool { pub const fn is_request(&self) -> bool {
matches!(self, Message::Request(_)) matches!(self, Self::Request(_))
} }
pub fn is_response(&self) -> bool { pub const fn is_response(&self) -> bool {
matches!(self, Message::Response(_)) matches!(self, Self::Response(_))
} }
pub fn is_protocol(&self) -> bool { pub const fn is_protocol(&self) -> bool {
matches!(self, Message::Protocol(_)) matches!(self, Self::Protocol(_))
} }
pub fn command(&self) -> LevinCommand { pub const fn command(&self) -> LevinCommand {
match self { match self {
Message::Request(mes) => mes.command(), Self::Request(mes) => mes.command(),
Message::Response(mes) => mes.command(), Self::Response(mes) => mes.command(),
Message::Protocol(mes) => mes.command(), Self::Protocol(mes) => mes.command(),
} }
} }
} }
@ -398,27 +399,25 @@ impl LevinBody for Message {
command: LevinCommand, command: LevinCommand,
) -> Result<Self, BucketError> { ) -> Result<Self, BucketError> {
Ok(match typ { Ok(match typ {
MessageType::Request => Message::Request(AdminRequestMessage::decode(body, command)?), MessageType::Request => Self::Request(AdminRequestMessage::decode(body, command)?),
MessageType::Response => { MessageType::Response => Self::Response(AdminResponseMessage::decode(body, command)?),
Message::Response(AdminResponseMessage::decode(body, command)?) MessageType::Notification => Self::Protocol(ProtocolMessage::decode(body, command)?),
}
MessageType::Notification => Message::Protocol(ProtocolMessage::decode(body, command)?),
}) })
} }
fn encode(self, builder: &mut BucketBuilder<LevinCommand>) -> Result<(), BucketError> { fn encode(self, builder: &mut BucketBuilder<LevinCommand>) -> Result<(), BucketError> {
match self { match self {
Message::Protocol(pro) => { Self::Protocol(pro) => {
builder.set_message_type(MessageType::Notification); builder.set_message_type(MessageType::Notification);
builder.set_return_code(0); builder.set_return_code(0);
pro.build(builder) pro.build(builder)
} }
Message::Request(req) => { Self::Request(req) => {
builder.set_message_type(MessageType::Request); builder.set_message_type(MessageType::Request);
builder.set_return_code(0); builder.set_return_code(0);
req.build(builder) req.build(builder)
} }
Message::Response(res) => { Self::Response(res) => {
builder.set_message_type(MessageType::Response); builder.set_message_type(MessageType::Response);
builder.set_return_code(1); builder.set_return_code(1);
res.build(builder) res.build(builder)

View file

@ -45,7 +45,7 @@ pub struct HandshakeResponse {
pub node_data: BasicNodeData, pub node_data: BasicNodeData,
/// Core Sync Data /// Core Sync Data
pub payload_data: CoreSyncData, pub payload_data: CoreSyncData,
/// PeerList /// `PeerList`
pub local_peerlist_new: Vec<PeerListEntryBase>, pub local_peerlist_new: Vec<PeerListEntryBase>,
} }
@ -56,7 +56,7 @@ epee_object!(
local_peerlist_new: Vec<PeerListEntryBase>, local_peerlist_new: Vec<PeerListEntryBase>,
); );
/// A TimedSync Request /// A `TimedSync` Request
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct TimedSyncRequest { pub struct TimedSyncRequest {
/// Core Sync Data /// Core Sync Data
@ -68,12 +68,12 @@ epee_object!(
payload_data: CoreSyncData, payload_data: CoreSyncData,
); );
/// A TimedSync Response /// A `TimedSync` Response
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct TimedSyncResponse { pub struct TimedSyncResponse {
/// Core Sync Data /// Core Sync Data
pub payload_data: CoreSyncData, pub payload_data: CoreSyncData,
/// PeerList /// `PeerList`
pub local_peerlist_new: Vec<PeerListEntryBase>, pub local_peerlist_new: Vec<PeerListEntryBase>,
} }

View file

@ -18,6 +18,7 @@
use bitflags::bitflags; use bitflags::bitflags;
use cuprate_epee_encoding::epee_object; use cuprate_epee_encoding::epee_object;
use cuprate_helper::map::split_u128_into_low_high_bits;
pub use cuprate_types::{BlockCompleteEntry, PrunedTxBlobEntry, TransactionBlobs}; pub use cuprate_types::{BlockCompleteEntry, PrunedTxBlobEntry, TransactionBlobs};
use crate::NetworkAddress; use crate::NetworkAddress;
@ -34,7 +35,7 @@ bitflags! {
impl From<u32> for PeerSupportFlags { impl From<u32> for PeerSupportFlags {
fn from(value: u32) -> Self { fn from(value: u32) -> Self {
PeerSupportFlags(value) Self(value)
} }
} }
@ -113,16 +114,17 @@ epee_object! {
} }
impl CoreSyncData { impl CoreSyncData {
pub fn new( pub const fn new(
cumulative_difficulty_128: u128, cumulative_difficulty_128: u128,
current_height: u64, current_height: u64,
pruning_seed: u32, pruning_seed: u32,
top_id: [u8; 32], top_id: [u8; 32],
top_version: u8, top_version: u8,
) -> CoreSyncData { ) -> Self {
let cumulative_difficulty = cumulative_difficulty_128 as u64; let (cumulative_difficulty, cumulative_difficulty_top64) =
let cumulative_difficulty_top64 = (cumulative_difficulty_128 >> 64) as u64; split_u128_into_low_high_bits(cumulative_difficulty_128);
CoreSyncData {
Self {
cumulative_difficulty, cumulative_difficulty,
cumulative_difficulty_top64, cumulative_difficulty_top64,
current_height, current_height,
@ -139,7 +141,7 @@ impl CoreSyncData {
} }
} }
/// PeerListEntryBase, information kept on a peer which will be entered /// `PeerListEntryBase`, information kept on a peer which will be entered
/// in a peer list/store. /// in a peer list/store.
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct PeerListEntryBase { pub struct PeerListEntryBase {

View file

@ -127,7 +127,7 @@ pub struct ChainResponse {
impl ChainResponse { impl ChainResponse {
#[inline] #[inline]
pub fn cumulative_difficulty(&self) -> u128 { pub const fn cumulative_difficulty(&self) -> u128 {
let cumulative_difficulty = self.cumulative_difficulty_top64 as u128; let cumulative_difficulty = self.cumulative_difficulty_top64 as u128;
cumulative_difficulty << 64 | self.cumulative_difficulty_low64 as u128 cumulative_difficulty << 64 | self.cumulative_difficulty_low64 as u128
} }
@ -159,7 +159,7 @@ epee_object!(
current_blockchain_height: u64, current_blockchain_height: u64,
); );
/// A request for Txs we are missing from our TxPool /// A request for Txs we are missing from our `TxPool`
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct FluffyMissingTransactionsRequest { pub struct FluffyMissingTransactionsRequest {
/// The Block we are missing the Txs in /// The Block we are missing the Txs in
@ -177,7 +177,7 @@ epee_object!(
missing_tx_indices: Vec<u64> as ContainerAsBlob<u64>, missing_tx_indices: Vec<u64> as ContainerAsBlob<u64>,
); );
/// TxPoolCompliment /// `TxPoolCompliment`
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct GetTxPoolCompliment { pub struct GetTxPoolCompliment {
/// Tx Hashes /// Tx Hashes