From b8e50eb96d91f45a3fb2edd03bb2b43ddac19331 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 21 Jun 2024 02:11:22 +0100 Subject: [PATCH] sort imports --- p2p/cuprate-p2p/src/block_downloader.rs | 11 +++----- .../src/block_downloader/download_batch.rs | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/p2p/cuprate-p2p/src/block_downloader.rs b/p2p/cuprate-p2p/src/block_downloader.rs index 0650df9b..289935d2 100644 --- a/p2p/cuprate-p2p/src/block_downloader.rs +++ b/p2p/cuprate-p2p/src/block_downloader.rs @@ -22,23 +22,18 @@ use tower::{Service, ServiceExt}; use tracing::{instrument, Instrument, Span}; use async_buffer::{BufferAppender, BufferStream}; -use cuprate_helper::asynch::rayon_spawn_async; -use fixed_bytes::ByteArrayVec; use monero_p2p::{ - client::InternalPeerID, handles::ConnectionHandle, services::{PeerSyncRequest, PeerSyncResponse}, - NetworkZone, PeerRequest, PeerResponse, PeerSyncSvc, + NetworkZone, PeerSyncSvc, }; use monero_pruning::{PruningSeed, CRYPTONOTE_MAX_BLOCK_HEIGHT}; -use monero_wire::protocol::{ChainRequest, ChainResponse}; use crate::{ client_pool::{ClientPool, ClientPoolDropGuard}, constants::{ - BLOCK_DOWNLOADER_REQUEST_TIMEOUT, EMPTY_CHAIN_ENTRIES_BEFORE_TOP_ASSUMED, - INITIAL_CHAIN_REQUESTS_TO_SEND, LONG_BAN, MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, - MAX_BLOCK_BATCH_LEN, MAX_DOWNLOAD_FAILURES, MEDIUM_BAN, + BLOCK_DOWNLOADER_REQUEST_TIMEOUT, EMPTY_CHAIN_ENTRIES_BEFORE_TOP_ASSUMED, LONG_BAN, + MAX_BLOCK_BATCH_LEN, MAX_DOWNLOAD_FAILURES, }, }; diff --git a/p2p/cuprate-p2p/src/block_downloader/download_batch.rs b/p2p/cuprate-p2p/src/block_downloader/download_batch.rs index 1ac01b08..f99714c4 100644 --- a/p2p/cuprate-p2p/src/block_downloader/download_batch.rs +++ b/p2p/cuprate-p2p/src/block_downloader/download_batch.rs @@ -1,37 +1,38 @@ -use cuprate_helper::asynch::rayon_spawn_async; -use fixed_bytes::ByteArrayVec; -use monero_p2p::handles::ConnectionHandle; -use monero_p2p::{NetworkZone, PeerRequest, PeerResponse}; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; -use monero_wire::protocol::{GetObjectsRequest, GetObjectsResponse}; -use rayon::prelude::*; use std::collections::HashSet; + +use monero_serai::{block::Block, transaction::Transaction}; +use rayon::prelude::*; use tokio::time::timeout; use tower::{Service, ServiceExt}; use tracing::instrument; -use crate::block_downloader::BlockDownloadTaskResponse; +use monero_p2p::{NetworkZone, PeerRequest, PeerResponse, handles::ConnectionHandle}; +use monero_wire::protocol::{GetObjectsRequest, GetObjectsResponse}; +use cuprate_helper::asynch::rayon_spawn_async; +use fixed_bytes::ByteArrayVec; + use crate::{ - block_downloader::{BlockBatch, BlockDownloadError}, + block_downloader::{BlockBatch, BlockDownloadError, BlockDownloadTaskResponse}, client_pool::ClientPoolDropGuard, constants::{BLOCK_DOWNLOADER_REQUEST_TIMEOUT, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN}, }; + +/// Attempts to request a batch of blocks from a peer, returning [`BlockDownloadTaskResponse`]. #[instrument( level = "debug", name = "download_batch", skip_all, fields( start_height = expected_start_height, - attempt + attempt = _attempt ) )] pub async fn download_batch_task( client: ClientPoolDropGuard, ids: ByteArrayVec<32>, expected_start_height: u64, - attempt: usize, + _attempt: usize, ) -> BlockDownloadTaskResponse { BlockDownloadTaskResponse { start_height: expected_start_height,