From 4af0145baa1a466559a116207ff59456f1e6a459 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 22:23:25 +0100 Subject: [PATCH] sort imports + docs --- binaries/cuprated/src/p2p/request_handler.rs | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index c868de9..0bf6ee2 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,36 +1,39 @@ -use bytes::Bytes; -use futures::future::BoxFuture; -use futures::FutureExt; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; -use std::collections::HashSet; use std::{ + collections::HashSet, future::{ready, Ready}, task::{Context, Poll}, }; + +use bytes::Bytes; +use futures::{future::BoxFuture, FutureExt}; +use monero_serai::{block::Block, transaction::Transaction}; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_consensus::BlockChainContextService; +use cuprate_consensus::{transactions::new_tx_verification_data, BlockChainContextService}; use cuprate_fixed_bytes::ByteArrayVec; -use cuprate_helper::asynch::rayon_spawn_async; -use cuprate_helper::cast::usize_to_u64; -use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; +use cuprate_helper::{ + asynch::rayon_spawn_async, + cast::usize_to_u64, + map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, +}; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; -use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::{BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs}; +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs, +}; use cuprate_wire::protocol::{ ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, GetObjectsResponse, NewFluffyBlock, }; -use crate::blockchain::interface as blockchain_interface; -use crate::blockchain::interface::IncomingBlockError; +use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockError}; +/// The P2P protocol request handler [`MakeService`](tower::MakeService). #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { + /// The [`BlockchainReadHandle`] pub blockchain_read_handle: BlockchainReadHandle, } @@ -55,9 +58,12 @@ impl Service> for P2pProtocolRequestHandlerMa } } +/// The P2P protocol request handler. #[derive(Clone)] pub struct P2pProtocolRequestHandler { + /// The [`PeerInformation`] for this peer. peer_information: PeerInformation, + /// The [`BlockchainReadHandle`] blockchain_read_handle: BlockchainReadHandle, }