mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
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:
parent
aeb070ae8d
commit
5648bf0da0
19 changed files with 255 additions and 322 deletions
|
@ -76,21 +76,12 @@
|
|||
// TODO
|
||||
rustdoc::bare_urls,
|
||||
|
||||
clippy::multiple_crate_versions,
|
||||
clippy::module_name_repetitions,
|
||||
clippy::module_inception,
|
||||
clippy::redundant_pub_crate,
|
||||
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.
|
||||
#![cfg_attr(
|
||||
test,
|
||||
|
@ -101,8 +92,6 @@
|
|||
clippy::too_many_lines
|
||||
)
|
||||
)]
|
||||
// TODO: remove me after finishing impl
|
||||
#![allow(dead_code, unreachable_code, clippy::diverging_sub_expression)]
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Mod
|
||||
mod route;
|
||||
|
|
|
@ -81,7 +81,7 @@ macro_rules! generate_endpoints_inner {
|
|||
// Serialize to bytes and respond.
|
||||
match cuprate_epee_encoding::to_bytes(response) {
|
||||
Ok(bytes) => Ok(bytes.freeze()),
|
||||
Err(e) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
//! Free functions.
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Use
|
||||
use axum::{
|
||||
routing::{method_routing::get, post},
|
||||
Router,
|
||||
};
|
||||
use axum::Router;
|
||||
|
||||
use crate::{
|
||||
route::{bin, fallback, json_rpc, other},
|
||||
|
|
|
@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
|
|||
pub enum RpcError {}
|
||||
|
||||
impl From<RpcError> for StatusCode {
|
||||
fn from(value: RpcError) -> Self {
|
||||
fn from(_: RpcError) -> Self {
|
||||
// TODO
|
||||
Self::INTERNAL_SERVER_ERROR
|
||||
}
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
//! RPC handler trait.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- 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 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};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- RpcHandler
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
//---------------------------------------------------------------------------------------------------- Use
|
||||
use std::task::Poll;
|
||||
|
||||
use futures::{channel::oneshot::channel, FutureExt};
|
||||
use futures::channel::oneshot::channel;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
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_handler::RpcHandler, rpc_request::RpcRequest,
|
||||
|
@ -48,7 +47,7 @@ impl Service<RpcRequest> for RpcHandlerDummy {
|
|||
type Error = 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(()))
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,6 @@
|
|||
clippy::redundant_pub_crate,
|
||||
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.
|
||||
#![cfg_attr(
|
||||
test,
|
||||
|
|
|
@ -13,22 +13,17 @@ use cuprate_epee_encoding::{
|
|||
container_as_blob::ContainerAsBlob,
|
||||
epee_object, error,
|
||||
macros::bytes::{Buf, BufMut},
|
||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue,
|
||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder,
|
||||
};
|
||||
|
||||
use cuprate_types::BlockCompleteEntry;
|
||||
|
||||
use crate::{
|
||||
base::{AccessResponseBase, ResponseBase},
|
||||
defaults::{default_false, default_height, default_string, default_vec, default_zero},
|
||||
free::{is_one, is_zero},
|
||||
base::AccessResponseBase,
|
||||
defaults::{default_false, default_zero},
|
||||
macros::{define_request, define_request_and_response, define_request_and_response_doc},
|
||||
misc::{
|
||||
AuxPow, BlockHeader, BlockOutputIndices, ChainInfo, ConnectionInfo, GetBan, GetOutputsOut,
|
||||
HardforkEntry, HistogramEntry, OutKeyBin, OutputDistributionData, Peer, PoolInfoExtent,
|
||||
PoolTxInfo, SetBan, Span, Status, TxBacklogEntry,
|
||||
},
|
||||
rpc_call::{RpcCall, RpcCallValue},
|
||||
misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolInfoExtent, PoolTxInfo, Status},
|
||||
rpc_call::RpcCallValue,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Definitions
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
//! `height`, it will use [`default_height`] to fill that in.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::borrow::Cow;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TODO
|
||||
/// Default [`bool`] type used in request/response types, `false`.
|
||||
|
@ -23,12 +22,6 @@ pub(crate) const fn default_true() -> bool {
|
|||
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.
|
||||
#[inline]
|
||||
pub(crate) const fn default_string() -> String {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
/// Returns `true` if the input `u` is equal to `0`.
|
||||
#[inline]
|
||||
#[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 {
|
||||
*u == 0
|
||||
}
|
||||
|
@ -13,6 +14,7 @@ pub(crate) const fn is_zero(u: &u64) -> bool {
|
|||
/// Returns `true` the input `u` is equal to `1`.
|
||||
#[inline]
|
||||
#[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 {
|
||||
*u == 1
|
||||
}
|
||||
|
|
|
@ -12,12 +12,11 @@ use crate::{
|
|||
default_false, default_height, default_one, default_string, default_true, default_vec,
|
||||
default_zero,
|
||||
},
|
||||
free::{is_one, is_zero},
|
||||
macros::define_request_and_response,
|
||||
misc::{
|
||||
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan,
|
||||
GetMinerDataTxBacklogEntry, HardforkEntry, HistogramEntry, OutputDistributionData, SetBan,
|
||||
Span, Status, SyncInfoPeer, TxBacklogEntry,
|
||||
GetMinerDataTxBacklogEntry, HardforkEntry, HistogramEntry, SetBan, Span, Status,
|
||||
SyncInfoPeer, TxBacklogEntry,
|
||||
},
|
||||
rpc_call::RpcCallValue,
|
||||
};
|
||||
|
|
|
@ -73,24 +73,12 @@
|
|||
// FIXME: good lint but is less clear in most cases.
|
||||
clippy::items_after_statements,
|
||||
|
||||
// TODO
|
||||
rustdoc::bare_urls,
|
||||
|
||||
clippy::multiple_crate_versions,
|
||||
clippy::module_name_repetitions,
|
||||
clippy::module_inception,
|
||||
clippy::redundant_pub_crate,
|
||||
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.
|
||||
#![cfg_attr(
|
||||
test,
|
||||
|
@ -101,11 +89,6 @@
|
|||
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 constants;
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
//! Output distributions for [`crate::json::GetOutputDistributionResponse`].
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Use
|
||||
use std::mem::size_of;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{ser::SerializeStruct, Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "epee")]
|
||||
use cuprate_epee_encoding::{
|
||||
epee_object, error,
|
||||
macros::bytes::{Buf, BufMut},
|
||||
read_epee_value, read_varint, write_field, write_varint, EpeeObject, EpeeObjectBuilder,
|
||||
EpeeValue, Marker,
|
||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Free
|
||||
|
@ -24,7 +21,7 @@ use cuprate_epee_encoding::{
|
|||
45..=55
|
||||
)]
|
||||
#[cfg(feature = "epee")]
|
||||
fn compress_integer_array(array: &[u64]) -> error::Result<Vec<u8>> {
|
||||
fn compress_integer_array(_: &[u64]) -> error::Result<Vec<u8>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
@ -36,7 +33,7 @@ fn compress_integer_array(array: &[u64]) -> error::Result<Vec<u8>> {
|
|||
"rpc/core_rpc_server_commands_defs.h",
|
||||
57..=72
|
||||
)]
|
||||
fn decompress_integer_array(array: &[u8]) -> Vec<u64> {
|
||||
fn decompress_integer_array(_: &[u8]) -> Vec<u64> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
@ -281,9 +278,9 @@ impl EpeeObject for Distribution {
|
|||
//---------------------------------------------------------------------------------------------------- Tests
|
||||
#[cfg(test)]
|
||||
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.
|
||||
|
||||
|
|
|
@ -5,23 +5,13 @@
|
|||
//! the [`crate::misc::ConnectionInfo`] struct defined here.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::fmt::Display;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "epee")]
|
||||
use cuprate_epee_encoding::{
|
||||
epee_object,
|
||||
macros::bytes::{Buf, BufMut},
|
||||
EpeeValue, Marker,
|
||||
};
|
||||
use cuprate_epee_encoding::epee_object;
|
||||
|
||||
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},
|
||||
macros::monero_definition_link,
|
||||
};
|
||||
|
|
|
@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[cfg(feature = "epee")]
|
||||
use cuprate_epee_encoding::{
|
||||
epee_object, error,
|
||||
error,
|
||||
macros::bytes::{Buf, BufMut},
|
||||
read_epee_value, write_field, EpeeObject, EpeeObjectBuilder, EpeeValue, Marker,
|
||||
EpeeObject, EpeeObjectBuilder,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxEntry
|
||||
|
@ -123,7 +123,7 @@ impl Default for TxEntry {
|
|||
//---------------------------------------------------------------------------------------------------- Epee
|
||||
#[cfg(feature = "epee")]
|
||||
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!()
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ impl EpeeObject for TxEntry {
|
|||
unreachable!()
|
||||
}
|
||||
|
||||
fn write_fields<B: BufMut>(self, w: &mut B) -> error::Result<()> {
|
||||
fn write_fields<B: BufMut>(self, _: &mut B) -> error::Result<()> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,9 @@ use crate::{
|
|||
defaults::{default_false, default_string, default_true, default_vec, default_zero},
|
||||
macros::define_request_and_response,
|
||||
misc::{
|
||||
GetOutputsOut, KeyImageSpentStatus, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status,
|
||||
TxEntry, TxInfo, TxpoolStats,
|
||||
GetOutputsOut, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status, TxEntry, TxInfo,
|
||||
TxpoolStats,
|
||||
},
|
||||
rpc_call::RpcCall,
|
||||
RpcCallValue,
|
||||
};
|
||||
|
||||
|
@ -191,7 +190,7 @@ define_request_and_response! {
|
|||
}
|
||||
)]
|
||||
AccessResponseBase {
|
||||
/// FIXME: These are [`KeyImageSpentStatus`] in [`u8`] form.
|
||||
/// FIXME: These are [`KeyImageSpentStatus`](crate::misc::KeyImageSpentStatus) in [`u8`] form.
|
||||
spent_status: Vec<u8>,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ where
|
|||
//---------------------------------------------------------------------------------------------------- Tests
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
// use super::*;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue