Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 46 additions & 57 deletions rpc/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
// Forbid lints.
// Our code, and code generated (e.g macros) cannot overrule these.
#![forbid(
// `unsafe` is allowed but it _must_ be
// commented with `SAFETY: reason`.
clippy::undocumented_unsafe_blocks,
// `unsafe` is allowed but it _must_ be
// commented with `SAFETY: reason`.
clippy::undocumented_unsafe_blocks,

// Never.
unused_unsafe,
redundant_semicolons,
unused_allocation,
coherence_leak_check,
while_true,
// Never.
unused_unsafe,
redundant_semicolons,
unused_allocation,
coherence_leak_check,
while_true,

// Maybe can be put into `#[deny]`.
unconditional_recursion,
for_loops_over_fallibles,
unused_braces,
unused_labels,
keyword_idents,
non_ascii_idents,
variant_size_differences,
// Maybe can be put into `#[deny]`.
unconditional_recursion,
for_loops_over_fallibles,
unused_braces,
unused_labels,
keyword_idents,
non_ascii_idents,
variant_size_differences,
single_use_lifetimes,

// Probably can be put into `#[deny]`.
future_incompatible,
let_underscore,
break_with_label_and_loop,
duplicate_macro_attributes,
exported_private_dependencies,
large_assignments,
overlapping_range_endpoints,
semicolon_in_expressions_from_macros,
noop_method_call,
// Probably can be put into `#[deny]`.
future_incompatible,
let_underscore,
break_with_label_and_loop,
duplicate_macro_attributes,
exported_private_dependencies,
large_assignments,
overlapping_range_endpoints,
semicolon_in_expressions_from_macros,
noop_method_call,
)]
// Deny lints.
// Some of these are `#[allow]`'ed on a per-case basis.
Expand All @@ -57,39 +57,30 @@
unreachable_pub
)]
#![allow(
// FIXME: this lint affects crates outside of
// `database/` for some reason, allow for now.
clippy::cargo_common_metadata,
// FIXME: this lint affects crates outside of
// `database/` for some reason, allow for now.
clippy::cargo_common_metadata,

// FIXME: adding `#[must_use]` onto everything
// might just be more annoying than useful...
// although it is sometimes nice.
clippy::must_use_candidate,
// FIXME: adding `#[must_use]` onto everything
// might just be more annoying than useful...
// although it is sometimes nice.
clippy::must_use_candidate,

// FIXME: good lint but too many false positives
// with our `Env` + `RwLock` setup.
clippy::significant_drop_tightening,
// FIXME: good lint but too many false positives
// with our `Env` + `RwLock` setup.
clippy::significant_drop_tightening,

// FIXME: good lint but is less clear in most cases.
clippy::items_after_statements,
// FIXME: good lint but is less clear in most cases.
clippy::items_after_statements,

// TODO
rustdoc::bare_urls,
// TODO
rustdoc::bare_urls,

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
)
clippy::multiple_crate_versions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the indenting is different here, I think the other lints are incorrect though not this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess rustfmt doesn't work inside #![], fixed in other crates too.

clippy::module_name_repetitions,
clippy::module_inception,
clippy::redundant_pub_crate,
clippy::option_if_let_else,
)]
// Allow some lints in tests.
#![cfg_attr(
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion rpc/interface/src/route/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions rpc/interface/src/router_builder.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
2 changes: 1 addition & 1 deletion rpc/interface/src/rpc_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 1 addition & 7 deletions rpc/interface/src/rpc_handler.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions rpc/interface/src/rpc_handler_dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(()))
}

Expand Down
90 changes: 44 additions & 46 deletions rpc/json-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@
// Forbid lints.
// Our code, and code generated (e.g macros) cannot overrule these.
#![forbid(
// `unsafe` is allowed but it _must_ be
// commented with `SAFETY: reason`.
clippy::undocumented_unsafe_blocks,
// `unsafe` is allowed but it _must_ be
// commented with `SAFETY: reason`.
clippy::undocumented_unsafe_blocks,

// Never.
unused_unsafe,
redundant_semicolons,
unused_allocation,
coherence_leak_check,
while_true,
// Never.
unused_unsafe,
redundant_semicolons,
unused_allocation,
coherence_leak_check,
while_true,

// Maybe can be put into `#[deny]`.
unconditional_recursion,
for_loops_over_fallibles,
unused_braces,
unused_labels,
keyword_idents,
non_ascii_idents,
variant_size_differences,
// Maybe can be put into `#[deny]`.
unconditional_recursion,
for_loops_over_fallibles,
unused_braces,
unused_labels,
keyword_idents,
non_ascii_idents,
variant_size_differences,
single_use_lifetimes,

// Probably can be put into `#[deny]`.
future_incompatible,
let_underscore,
break_with_label_and_loop,
duplicate_macro_attributes,
exported_private_dependencies,
large_assignments,
overlapping_range_endpoints,
semicolon_in_expressions_from_macros,
noop_method_call,
unreachable_pub,
// Probably can be put into `#[deny]`.
future_incompatible,
let_underscore,
break_with_label_and_loop,
duplicate_macro_attributes,
exported_private_dependencies,
large_assignments,
overlapping_range_endpoints,
semicolon_in_expressions_from_macros,
noop_method_call,
unreachable_pub,
)]
// Deny lints.
// Some of these are `#[allow]`'ed on a per-case basis.
Expand All @@ -56,29 +56,27 @@
nonstandard_style
)]
#![allow(
// FIXME: this lint affects crates outside of
// `database/` for some reason, allow for now.
clippy::cargo_common_metadata,
// FIXME: this lint affects crates outside of
// `database/` for some reason, allow for now.
clippy::cargo_common_metadata,

// FIXME: adding `#[must_use]` onto everything
// might just be more annoying than useful...
// although it is sometimes nice.
clippy::must_use_candidate,
// FIXME: adding `#[must_use]` onto everything
// might just be more annoying than useful...
// although it is sometimes nice.
clippy::must_use_candidate,

// FIXME: good lint but too many false positives
// with our `Env` + `RwLock` setup.
clippy::significant_drop_tightening,
// FIXME: good lint but too many false positives
// with our `Env` + `RwLock` setup.
clippy::significant_drop_tightening,

// FIXME: good lint but is less clear in most cases.
clippy::items_after_statements,
// FIXME: good lint but is less clear in most cases.
clippy::items_after_statements,

clippy::module_name_repetitions,
clippy::module_inception,
clippy::redundant_pub_crate,
clippy::option_if_let_else,
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))]
// Allow some lints in tests.
#![cfg_attr(
test,
Expand Down
15 changes: 5 additions & 10 deletions rpc/types/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions rpc/types/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions rpc/types/src/free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
/// 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
}

/// 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
}
Loading
Loading