mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-11-16 15:58:17 +00:00
review fixes
This commit is contained in:
parent
defef01dce
commit
6470c160da
6 changed files with 26 additions and 35 deletions
|
@ -27,6 +27,8 @@ use crate::{
|
|||
|
||||
#[cfg(any(feature = "epee", feature = "serde"))]
|
||||
use crate::defaults::{default_false, default_zero};
|
||||
#[cfg(feature = "epee")]
|
||||
use crate::misc::PoolInfoExtent;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Definitions
|
||||
define_request_and_response! {
|
||||
|
@ -139,15 +141,15 @@ define_request! {
|
|||
core_rpc_server_commands_defs, h, 162, 262,
|
||||
)]
|
||||
///
|
||||
/// This response's variant depends upon [`crate::misc::PoolInfoExtent`].
|
||||
/// This response's variant depends upon [`PoolInfoExtent`].
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum GetBlocksResponse {
|
||||
/// Will always serialize a [`crate::misc::PoolInfoExtent::None`] field.
|
||||
/// Will always serialize a [`PoolInfoExtent::None`] field.
|
||||
PoolInfoNone(GetBlocksResponsePoolInfoNone),
|
||||
/// Will always serialize a [`crate::misc::PoolInfoExtent::Incremental`] field.
|
||||
/// Will always serialize a [`PoolInfoExtent::Incremental`] field.
|
||||
PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental),
|
||||
/// Will always serialize a [`crate::misc::PoolInfoExtent::Full`] field.
|
||||
/// Will always serialize a [`PoolInfoExtent::Full`] field.
|
||||
PoolInfoFull(GetBlocksResponsePoolInfoFull),
|
||||
}
|
||||
|
||||
|
@ -256,7 +258,7 @@ pub struct __GetBlocksResponseEpeeBuilder {
|
|||
pub current_height: Option<u64>,
|
||||
pub output_indices: Option<Vec<BlockOutputIndices>>,
|
||||
pub daemon_time: Option<u64>,
|
||||
pub pool_info_extent: Option<crate::misc::PoolInfoExtent>,
|
||||
pub pool_info_extent: Option<PoolInfoExtent>,
|
||||
pub added_pool_txs: Option<Vec<PoolTxInfo>>,
|
||||
pub remaining_added_pool_txids: Option<ByteArrayVec<32>>,
|
||||
pub removed_pool_txids: Option<ByteArrayVec<32>>,
|
||||
|
@ -306,7 +308,7 @@ impl EpeeObjectBuilder<GetBlocksResponse> for __GetBlocksResponseEpeeBuilder {
|
|||
let pool_info_extent = self.pool_info_extent.ok_or(ELSE)?;
|
||||
|
||||
let this = match pool_info_extent {
|
||||
crate::misc::PoolInfoExtent::None => {
|
||||
PoolInfoExtent::None => {
|
||||
GetBlocksResponse::PoolInfoNone(GetBlocksResponsePoolInfoNone {
|
||||
status,
|
||||
untrusted,
|
||||
|
@ -317,7 +319,7 @@ impl EpeeObjectBuilder<GetBlocksResponse> for __GetBlocksResponseEpeeBuilder {
|
|||
daemon_time,
|
||||
})
|
||||
}
|
||||
crate::misc::PoolInfoExtent::Incremental => {
|
||||
PoolInfoExtent::Incremental => {
|
||||
GetBlocksResponse::PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental {
|
||||
status,
|
||||
untrusted,
|
||||
|
@ -331,7 +333,7 @@ impl EpeeObjectBuilder<GetBlocksResponse> for __GetBlocksResponseEpeeBuilder {
|
|||
removed_pool_txids: self.removed_pool_txids.ok_or(ELSE)?,
|
||||
})
|
||||
}
|
||||
crate::misc::PoolInfoExtent::Full => {
|
||||
PoolInfoExtent::Full => {
|
||||
GetBlocksResponse::PoolInfoFull(GetBlocksResponsePoolInfoFull {
|
||||
status,
|
||||
untrusted,
|
||||
|
@ -355,7 +357,7 @@ impl EpeeObject for GetBlocksResponse {
|
|||
type Builder = __GetBlocksResponseEpeeBuilder;
|
||||
|
||||
fn number_of_fields(&self) -> u64 {
|
||||
// [`crate::misc::PoolInfoExtent`] + inner struct fields.
|
||||
// [`PoolInfoExtent`] + inner struct fields.
|
||||
let inner_fields = match self {
|
||||
Self::PoolInfoNone(s) => s.number_of_fields(),
|
||||
Self::PoolInfoIncremental(s) => s.number_of_fields(),
|
||||
|
@ -369,27 +371,15 @@ impl EpeeObject for GetBlocksResponse {
|
|||
match self {
|
||||
Self::PoolInfoNone(s) => {
|
||||
s.write_fields(w)?;
|
||||
write_field(
|
||||
crate::misc::PoolInfoExtent::None.to_u8(),
|
||||
"pool_info_extent",
|
||||
w,
|
||||
)?;
|
||||
write_field(PoolInfoExtent::None.to_u8(), "pool_info_extent", w)?;
|
||||
}
|
||||
Self::PoolInfoIncremental(s) => {
|
||||
s.write_fields(w)?;
|
||||
write_field(
|
||||
crate::misc::PoolInfoExtent::Incremental.to_u8(),
|
||||
"pool_info_extent",
|
||||
w,
|
||||
)?;
|
||||
write_field(PoolInfoExtent::Incremental.to_u8(), "pool_info_extent", w)?;
|
||||
}
|
||||
Self::PoolInfoFull(s) => {
|
||||
s.write_fields(w)?;
|
||||
write_field(
|
||||
crate::misc::PoolInfoExtent::Full.to_u8(),
|
||||
"pool_info_extent",
|
||||
w,
|
||||
)?;
|
||||
write_field(PoolInfoExtent::Full.to_u8(), "pool_info_extent", w)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ thiserror = { workspace = true }
|
|||
hex = { workspace = true, features = ["std"] }
|
||||
blake3 = { workspace = true, features = ["std"] }
|
||||
|
||||
tower = { workspace = true }
|
||||
rayon = { workspace = true }
|
||||
|
||||
serde = { workspace = true, optional = true }
|
||||
|
@ -38,7 +39,6 @@ serde = { workspace = true, optional = true }
|
|||
cuprate-test-utils = { workspace = true }
|
||||
|
||||
tokio = { workspace = true }
|
||||
tower = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
hex-literal = { workspace = true }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ This crate does 3 things:
|
|||
|
||||
1. Uses [`cuprate_database`] as a base database layer
|
||||
1. Implements various transaction pool related [operations](ops), [tables], and [types]
|
||||
1. Exposes a `tower::Service` backed by a thread-pool
|
||||
1. Exposes a [`tower::Service`] backed by a thread-pool
|
||||
|
||||
Each layer builds on-top of the previous.
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
clippy::significant_drop_tightening
|
||||
)]
|
||||
|
||||
use tower as _;
|
||||
|
||||
pub mod config;
|
||||
mod free;
|
||||
pub mod ops;
|
||||
|
@ -25,5 +27,4 @@ mod test {
|
|||
use hex_literal as _;
|
||||
use tempfile as _;
|
||||
use tokio as _;
|
||||
use tower as _;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! `tower::Service` integeration + thread-pool.
|
||||
//! [`tower::Service`] integeration + thread-pool.
|
||||
//!
|
||||
//! ## `service`
|
||||
//! The `service` module implements the `tower` integration,
|
||||
//! The `service` module implements the [`tower`] integration,
|
||||
//! along with the reader/writer thread-pool system.
|
||||
//!
|
||||
//! The thread-pool allows outside crates to communicate with it by
|
||||
|
@ -42,7 +42,7 @@
|
|||
//! To interact with the database (whether reading or writing data),
|
||||
//! a `Request` can be sent using one of the above handles.
|
||||
//!
|
||||
//! Both the handles implement `tower::Service`, so they can be `tower::Service::call`ed.
|
||||
//! Both the handles implement [`tower::Service`], so they can be [`tower::Service::call`]ed.
|
||||
//!
|
||||
//! An `async`hronous channel will be returned from the call.
|
||||
//! This channel can be `.await`ed upon to (eventually) receive
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Tx-pool [`service`](super) interface.
|
||||
//!
|
||||
//! This module contains `cuprate_txpool`'s `tower::Service` request and response enums.
|
||||
//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums.
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolReadRequest
|
||||
/// The transaction pool `tower::Service` read request type.
|
||||
/// The transaction pool [`tower::Service`] read request type.
|
||||
#[derive(Clone)]
|
||||
pub enum TxpoolReadRequest {
|
||||
/// Get the blob (raw bytes) of a transaction with the given hash.
|
||||
|
@ -39,7 +39,7 @@ pub enum TxpoolReadRequest {
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolReadResponse
|
||||
/// The transaction pool `tower::Service` read response type.
|
||||
/// The transaction pool [`tower::Service`] read response type.
|
||||
#[expect(clippy::large_enum_variant)]
|
||||
pub enum TxpoolReadResponse {
|
||||
/// The response for [`TxpoolReadRequest::TxBlob`].
|
||||
|
@ -78,7 +78,7 @@ pub enum TxpoolReadResponse {
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteRequest
|
||||
/// The transaction pool `tower::Service` write request type.
|
||||
/// The transaction pool [`tower::Service`] write request type.
|
||||
#[derive(Clone)]
|
||||
pub enum TxpoolWriteRequest {
|
||||
/// Add a transaction to the pool.
|
||||
|
@ -108,7 +108,7 @@ pub enum TxpoolWriteRequest {
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolWriteResponse
|
||||
/// The transaction pool `tower::Service` write response type.
|
||||
/// The transaction pool [`tower::Service`] write response type.
|
||||
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
|
||||
pub enum TxpoolWriteResponse {
|
||||
/// Response to:
|
||||
|
|
Loading…
Reference in a new issue