diff --git a/Cargo.lock b/Cargo.lock index 0e507c41..5ff43dfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,6 +50,16 @@ dependencies = [ "libc", ] +[[package]] +name = "async-buffer" +version = "0.1.0" +dependencies = [ + "futures", + "pin-project", + "thiserror", + "tokio", +] + [[package]] name = "async-lock" version = "3.3.0" @@ -502,6 +512,7 @@ dependencies = [ name = "cuprate-p2p" version = "0.1.0" dependencies = [ + "async-buffer", "bytes", "cuprate-helper", "cuprate-test-utils", @@ -525,6 +536,7 @@ dependencies = [ "tokio-util", "tower", "tracing", + "tracing-subscriber", ] [[package]] @@ -613,7 +625,7 @@ dependencies = [ ] [[package]] -name = "dandelion_tower" +name = "dandelion-tower" version = "0.1.0" dependencies = [ "futures", @@ -1463,6 +1475,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -1510,6 +1532,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "page_size" version = "0.6.0" @@ -2136,6 +2164,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -2476,6 +2513,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] [[package]] @@ -2484,7 +2533,12 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -2543,6 +2597,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" diff --git a/p2p/cuprate-p2p/src/bin/test_init.rs b/p2p/cuprate-p2p/src/bin/test_init.rs index 248e389e..181cdfca 100644 --- a/p2p/cuprate-p2p/src/bin/test_init.rs +++ b/p2p/cuprate-p2p/src/bin/test_init.rs @@ -153,30 +153,24 @@ async fn main() { sleep(Duration::from_secs(15)).await; - loop { - let mut buffer = download_blocks( - net.pool.clone(), - net.sync_states_svc.clone(), - OurChainSvc, - BlockDownloaderConfig { - buffer_size: 50_000_000, - in_progress_queue_size: 30_000_000, - check_client_pool_interval: Duration::from_secs(10), - target_batch_size: 5_000_000, - initial_batch_size: 10, - }, - ); + let mut buffer = download_blocks( + net.pool.clone(), + net.sync_states_svc.clone(), + OurChainSvc, + BlockDownloaderConfig { + buffer_size: 50_000_000, + in_progress_queue_size: 30_000_000, + check_client_pool_interval: Duration::from_secs(10), + target_batch_size: 5_000_000, + initial_batch_size: 10, + }, + ); - while let Some(entry) = buffer.next().await { - tracing::info!( - "height: {}, amount{}", - entry.blocks[0].0.number().unwrap(), - entry.blocks.len() - ) - } - - panic!(); - - sleep(Duration::from_secs(2)).await; + while let Some(entry) = buffer.next().await { + tracing::info!( + "height: {}, amount{}", + entry.blocks[0].0.number().unwrap(), + entry.blocks.len() + ) } } diff --git a/p2p/cuprate-p2p/src/block_downloader.rs b/p2p/cuprate-p2p/src/block_downloader.rs index 4404bfc2..7e3a2136 100644 --- a/p2p/cuprate-p2p/src/block_downloader.rs +++ b/p2p/cuprate-p2p/src/block_downloader.rs @@ -3,9 +3,8 @@ mod chain_tracker; -use futures::FutureExt; use std::cmp::{max, min, Ordering, Reverse}; -use std::collections::{BTreeMap, BinaryHeap, HashSet, VecDeque}; +use std::collections::{BTreeMap, BinaryHeap, HashSet}; use std::sync::Arc; use std::time::Duration; diff --git a/p2p/cuprate-p2p/src/lib.rs b/p2p/cuprate-p2p/src/lib.rs index 0b864713..b55c216e 100644 --- a/p2p/cuprate-p2p/src/lib.rs +++ b/p2p/cuprate-p2p/src/lib.rs @@ -20,6 +20,7 @@ use monero_p2p::{ CoreSyncSvc, NetworkZone, PeerRequestHandler, }; +pub mod block_downloader; mod broadcast; mod client_pool; pub mod config;