rpc: remove temporary lints (#255)

* rpc: remove temporary lints for types

* rpc: remove temporary lints for json-rpc

* rpc: remove temporary lints for interface

* cfgs `1 tab` -> `4 spaces`
This commit is contained in:
hinto-janai 2024-08-20 18:50:31 -04:00 committed by GitHub
parent aeb070ae8d
commit 5648bf0da0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 255 additions and 322 deletions

View file

@ -76,21 +76,12 @@
// TODO // TODO
rustdoc::bare_urls, rustdoc::bare_urls,
clippy::multiple_crate_versions,
clippy::module_name_repetitions, clippy::module_name_repetitions,
clippy::module_inception, clippy::module_inception,
clippy::redundant_pub_crate, clippy::redundant_pub_crate,
clippy::option_if_let_else, clippy::option_if_let_else,
)] )]
// Allow some lints when running in debug mode.
#![cfg_attr(
debug_assertions,
allow(
clippy::todo,
clippy::multiple_crate_versions,
unused_imports,
unused_variables
)
)]
// Allow some lints in tests. // Allow some lints in tests.
#![cfg_attr( #![cfg_attr(
test, test,
@ -101,8 +92,6 @@
clippy::too_many_lines clippy::too_many_lines
) )
)] )]
// TODO: remove me after finishing impl
#![allow(dead_code, unreachable_code, clippy::diverging_sub_expression)]
//---------------------------------------------------------------------------------------------------- Mod //---------------------------------------------------------------------------------------------------- Mod
mod route; mod route;

View file

@ -81,7 +81,7 @@ macro_rules! generate_endpoints_inner {
// Serialize to bytes and respond. // Serialize to bytes and respond.
match cuprate_epee_encoding::to_bytes(response) { match cuprate_epee_encoding::to_bytes(response) {
Ok(bytes) => Ok(bytes.freeze()), Ok(bytes) => Ok(bytes.freeze()),
Err(e) => Err(StatusCode::INTERNAL_SERVER_ERROR), Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
} }
} }
} }

View file

@ -1,12 +1,7 @@
//! Free functions. //! Free functions.
use std::marker::PhantomData;
//---------------------------------------------------------------------------------------------------- Use //---------------------------------------------------------------------------------------------------- Use
use axum::{ use axum::Router;
routing::{method_routing::get, post},
Router,
};
use crate::{ use crate::{
route::{bin, fallback, json_rpc, other}, route::{bin, fallback, json_rpc, other},

View file

@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
pub enum RpcError {} pub enum RpcError {}
impl From<RpcError> for StatusCode { impl From<RpcError> for StatusCode {
fn from(value: RpcError) -> Self { fn from(_: RpcError) -> Self {
// TODO // TODO
Self::INTERNAL_SERVER_ERROR Self::INTERNAL_SERVER_ERROR
} }

View file

@ -1,16 +1,10 @@
//! RPC handler trait. //! RPC handler trait.
//---------------------------------------------------------------------------------------------------- Use //---------------------------------------------------------------------------------------------------- Use
use std::{future::Future, task::Poll}; use std::future::Future;
use axum::{http::StatusCode, response::IntoResponse};
use futures::{channel::oneshot::channel, FutureExt};
use tower::Service; use tower::Service;
use cuprate_helper::asynch::InfallibleOneshotReceiver;
use cuprate_json_rpc::Id;
use cuprate_rpc_types::json::JsonRpcRequest;
use crate::{rpc_error::RpcError, rpc_request::RpcRequest, rpc_response::RpcResponse}; use crate::{rpc_error::RpcError, rpc_request::RpcRequest, rpc_response::RpcResponse};
//---------------------------------------------------------------------------------------------------- RpcHandler //---------------------------------------------------------------------------------------------------- RpcHandler

View file

@ -3,14 +3,13 @@
//---------------------------------------------------------------------------------------------------- Use //---------------------------------------------------------------------------------------------------- Use
use std::task::Poll; use std::task::Poll;
use futures::{channel::oneshot::channel, FutureExt}; use futures::channel::oneshot::channel;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tower::Service; use tower::Service;
use cuprate_helper::asynch::InfallibleOneshotReceiver; use cuprate_helper::asynch::InfallibleOneshotReceiver;
use cuprate_json_rpc::Id; use cuprate_json_rpc::Id;
use cuprate_rpc_types::json::JsonRpcRequest;
use crate::{ use crate::{
rpc_error::RpcError, rpc_handler::RpcHandler, rpc_request::RpcRequest, rpc_error::RpcError, rpc_handler::RpcHandler, rpc_request::RpcRequest,
@ -48,7 +47,7 @@ impl Service<RpcRequest> for RpcHandlerDummy {
type Error = RpcError; type Error = RpcError;
type Future = InfallibleOneshotReceiver<Result<RpcResponse, RpcError>>; type Future = InfallibleOneshotReceiver<Result<RpcResponse, RpcError>>;
fn poll_ready(&mut self, cx: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, _: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }

View file

@ -77,8 +77,6 @@
clippy::redundant_pub_crate, clippy::redundant_pub_crate,
clippy::option_if_let_else, clippy::option_if_let_else,
)] )]
// Allow some lints when running in debug mode.
#![cfg_attr(debug_assertions, allow(clippy::todo, clippy::multiple_crate_versions))]
// Allow some lints in tests. // Allow some lints in tests.
#![cfg_attr( #![cfg_attr(
test, test,

View file

@ -13,22 +13,17 @@ use cuprate_epee_encoding::{
container_as_blob::ContainerAsBlob, container_as_blob::ContainerAsBlob,
epee_object, error, epee_object, error,
macros::bytes::{Buf, BufMut}, macros::bytes::{Buf, BufMut},
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue, read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
}; };
use cuprate_types::BlockCompleteEntry; use cuprate_types::BlockCompleteEntry;
use crate::{ use crate::{
base::{AccessResponseBase, ResponseBase}, base::AccessResponseBase,
defaults::{default_false, default_height, default_string, default_vec, default_zero}, defaults::{default_false, default_zero},
free::{is_one, is_zero},
macros::{define_request, define_request_and_response, define_request_and_response_doc}, macros::{define_request, define_request_and_response, define_request_and_response_doc},
misc::{ misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolInfoExtent, PoolTxInfo, Status},
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan, GetOutputsOut, rpc_call::RpcCallValue,
HardforkEntry, HistogramEntry, OutKeyBin, OutputDistributionData, Peer, PoolInfoExtent,
PoolTxInfo, SetBan, Span, Status, TxBacklogEntry,
},
rpc_call::{RpcCall, RpcCallValue},
}; };
//---------------------------------------------------------------------------------------------------- Definitions //---------------------------------------------------------------------------------------------------- Definitions

View file

@ -8,7 +8,6 @@
//! `height`, it will use [`default_height`] to fill that in. //! `height`, it will use [`default_height`] to fill that in.
//---------------------------------------------------------------------------------------------------- Import //---------------------------------------------------------------------------------------------------- Import
use std::borrow::Cow;
//---------------------------------------------------------------------------------------------------- TODO //---------------------------------------------------------------------------------------------------- TODO
/// Default [`bool`] type used in request/response types, `false`. /// Default [`bool`] type used in request/response types, `false`.
@ -23,12 +22,6 @@ pub(crate) const fn default_true() -> bool {
true true
} }
/// Default `Cow<'static, str` type used in request/response types.
#[inline]
pub(crate) const fn default_cow_str() -> Cow<'static, str> {
Cow::Borrowed("")
}
/// Default [`String`] type used in request/response types. /// Default [`String`] type used in request/response types.
#[inline] #[inline]
pub(crate) const fn default_string() -> String { pub(crate) const fn default_string() -> String {

View file

@ -6,6 +6,7 @@
/// Returns `true` if the input `u` is equal to `0`. /// Returns `true` if the input `u` is equal to `0`.
#[inline] #[inline]
#[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&` #[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&`
#[allow(dead_code)] // TODO: see if needed after handlers.
pub(crate) const fn is_zero(u: &u64) -> bool { pub(crate) const fn is_zero(u: &u64) -> bool {
*u == 0 *u == 0
} }
@ -13,6 +14,7 @@ pub(crate) const fn is_zero(u: &u64) -> bool {
/// Returns `true` the input `u` is equal to `1`. /// Returns `true` the input `u` is equal to `1`.
#[inline] #[inline]
#[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&` #[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&`
#[allow(dead_code)] // TODO: see if needed after handlers.
pub(crate) const fn is_one(u: &u64) -> bool { pub(crate) const fn is_one(u: &u64) -> bool {
*u == 1 *u == 1
} }

View file

@ -12,12 +12,11 @@ use crate::{
default_false, default_height, default_one, default_string, default_true, default_vec, default_false, default_height, default_one, default_string, default_true, default_vec,
default_zero, default_zero,
}, },
free::{is_one, is_zero},
macros::define_request_and_response, macros::define_request_and_response,
misc::{ misc::{
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan, AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan,
GetMinerDataTxBacklogEntry, HardforkEntry, HistogramEntry, OutputDistributionData, SetBan, GetMinerDataTxBacklogEntry, HardforkEntry, HistogramEntry, SetBan, Span, Status,
Span, Status, SyncInfoPeer, TxBacklogEntry, SyncInfoPeer, TxBacklogEntry,
}, },
rpc_call::RpcCallValue, rpc_call::RpcCallValue,
}; };

View file

@ -73,24 +73,12 @@
// FIXME: good lint but is less clear in most cases. // FIXME: good lint but is less clear in most cases.
clippy::items_after_statements, clippy::items_after_statements,
// TODO clippy::multiple_crate_versions,
rustdoc::bare_urls,
clippy::module_name_repetitions, clippy::module_name_repetitions,
clippy::module_inception, clippy::module_inception,
clippy::redundant_pub_crate, clippy::redundant_pub_crate,
clippy::option_if_let_else, clippy::option_if_let_else,
)] )]
// Allow some lints when running in debug mode.
#![cfg_attr(
debug_assertions,
allow(
clippy::todo,
clippy::multiple_crate_versions,
unused_imports,
unused_variables
)
)]
// Allow some lints in tests. // Allow some lints in tests.
#![cfg_attr( #![cfg_attr(
test, test,
@ -101,11 +89,6 @@
clippy::too_many_lines clippy::too_many_lines
) )
)] )]
// TODO: remove me after finishing impl
#![allow(
dead_code,
rustdoc::broken_intra_doc_links // TODO: remove after `{bin,json,other}.rs` gets merged
)]
//---------------------------------------------------------------------------------------------------- Mod //---------------------------------------------------------------------------------------------------- Mod
mod constants; mod constants;

View file

@ -1,17 +1,14 @@
//! Output distributions for [`crate::json::GetOutputDistributionResponse`]. //! Output distributions for [`crate::json::GetOutputDistributionResponse`].
//---------------------------------------------------------------------------------------------------- Use //---------------------------------------------------------------------------------------------------- Use
use std::mem::size_of;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{ser::SerializeStruct, Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(feature = "epee")] #[cfg(feature = "epee")]
use cuprate_epee_encoding::{ use cuprate_epee_encoding::{
epee_object, error, epee_object, error,
macros::bytes::{Buf, BufMut}, macros::bytes::{Buf, BufMut},
read_epee_value, read_varint, write_field, write_varint, EpeeObject, EpeeObjectBuilder, read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue,
EpeeValue, Marker,
}; };
//---------------------------------------------------------------------------------------------------- Free //---------------------------------------------------------------------------------------------------- Free
@ -24,7 +21,7 @@ use cuprate_epee_encoding::{
45..=55 45..=55
)] )]
#[cfg(feature = "epee")] #[cfg(feature = "epee")]
fn compress_integer_array(array: &[u64]) -> error::Result<Vec<u8>> { fn compress_integer_array(_: &[u64]) -> error::Result<Vec<u8>> {
todo!() todo!()
} }
@ -36,7 +33,7 @@ fn compress_integer_array(array: &[u64]) -> error::Result<Vec<u8>> {
"rpc/core_rpc_server_commands_defs.h", "rpc/core_rpc_server_commands_defs.h",
57..=72 57..=72
)] )]
fn decompress_integer_array(array: &[u8]) -> Vec<u64> { fn decompress_integer_array(_: &[u8]) -> Vec<u64> {
todo!() todo!()
} }
@ -281,9 +278,9 @@ impl EpeeObject for Distribution {
//---------------------------------------------------------------------------------------------------- Tests //---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use pretty_assertions::assert_eq; // use pretty_assertions::assert_eq;
use super::*; // use super::*;
// TODO: re-enable tests after (de)compression functions are implemented. // TODO: re-enable tests after (de)compression functions are implemented.

View file

@ -5,23 +5,13 @@
//! the [`crate::misc::ConnectionInfo`] struct defined here. //! the [`crate::misc::ConnectionInfo`] struct defined here.
//---------------------------------------------------------------------------------------------------- Import //---------------------------------------------------------------------------------------------------- Import
use std::fmt::Display;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(feature = "epee")] #[cfg(feature = "epee")]
use cuprate_epee_encoding::{ use cuprate_epee_encoding::epee_object;
epee_object,
macros::bytes::{Buf, BufMut},
EpeeValue, Marker,
};
use crate::{ use crate::{
constants::{
CORE_RPC_STATUS_BUSY, CORE_RPC_STATUS_NOT_MINING, CORE_RPC_STATUS_OK,
CORE_RPC_STATUS_PAYMENT_REQUIRED,
},
defaults::{default_string, default_zero}, defaults::{default_string, default_zero},
macros::monero_definition_link, macros::monero_definition_link,
}; };

View file

@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "epee")] #[cfg(feature = "epee")]
use cuprate_epee_encoding::{ use cuprate_epee_encoding::{
epee_object, error, error,
macros::bytes::{Buf, BufMut}, macros::bytes::{Buf, BufMut},
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue, Marker, EpeeObject, EpeeObjectBuilder,
}; };
//---------------------------------------------------------------------------------------------------- TxEntry //---------------------------------------------------------------------------------------------------- TxEntry
@ -123,7 +123,7 @@ impl Default for TxEntry {
//---------------------------------------------------------------------------------------------------- Epee //---------------------------------------------------------------------------------------------------- Epee
#[cfg(feature = "epee")] #[cfg(feature = "epee")]
impl EpeeObjectBuilder<TxEntry> for () { impl EpeeObjectBuilder<TxEntry> for () {
fn add_field<B: Buf>(&mut self, name: &str, r: &mut B) -> error::Result<bool> { fn add_field<B: Buf>(&mut self, _: &str, _: &mut B) -> error::Result<bool> {
unreachable!() unreachable!()
} }
@ -140,7 +140,7 @@ impl EpeeObject for TxEntry {
unreachable!() unreachable!()
} }
fn write_fields<B: BufMut>(self, w: &mut B) -> error::Result<()> { fn write_fields<B: BufMut>(self, _: &mut B) -> error::Result<()> {
unreachable!() unreachable!()
} }
} }

View file

@ -11,10 +11,9 @@ use crate::{
defaults::{default_false, default_string, default_true, default_vec, default_zero}, defaults::{default_false, default_string, default_true, default_vec, default_zero},
macros::define_request_and_response, macros::define_request_and_response,
misc::{ misc::{
GetOutputsOut, KeyImageSpentStatus, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status, GetOutputsOut, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status, TxEntry, TxInfo,
TxEntry, TxInfo, TxpoolStats, TxpoolStats,
}, },
rpc_call::RpcCall,
RpcCallValue, RpcCallValue,
}; };
@ -191,7 +190,7 @@ define_request_and_response! {
} }
)] )]
AccessResponseBase { AccessResponseBase {
/// FIXME: These are [`KeyImageSpentStatus`] in [`u8`] form. /// FIXME: These are [`KeyImageSpentStatus`](crate::misc::KeyImageSpentStatus) in [`u8`] form.
spent_status: Vec<u8>, spent_status: Vec<u8>,
} }
} }

View file

@ -28,5 +28,5 @@ where
//---------------------------------------------------------------------------------------------------- Tests //---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; // use super::*;
} }