Skip to content

Commit 59e346a

Browse files
committed
more peer set changes
1 parent b92e62d commit 59e346a

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

p2p/p2p/src/block_downloader.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use std::{
99
cmp::{max, min, Reverse},
1010
collections::{BTreeMap, BinaryHeap},
11-
sync::Arc,
1211
time::Duration,
1312
};
1413

p2p/p2p/src/block_downloader/request_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{mem, sync::Arc};
1+
use std::mem;
22

33
use tokio::{task::JoinSet, time::timeout};
44
use tower::util::BoxCloneService;

p2p/p2p/src/block_downloader/tests.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ use std::{
77
time::Duration,
88
};
99

10-
use futures::{FutureExt, StreamExt};
11-
use indexmap::IndexMap;
12-
use monero_serai::{
13-
block::{Block, BlockHeader},
14-
transaction::{Input, Timelock, Transaction, TransactionPrefix},
15-
};
16-
use proptest::{collection::vec, prelude::*};
17-
use tokio::time::timeout;
18-
use tower::{service_fn, Service};
19-
2010
use cuprate_fixed_bytes::ByteArrayVec;
2111
use cuprate_p2p_core::{
2212
client::{mock_client, Client, InternalPeerID, PeerInformation},
@@ -28,10 +18,21 @@ use cuprate_wire::{
2818
protocol::{ChainResponse, GetObjectsResponse},
2919
CoreSyncData,
3020
};
21+
use futures::{FutureExt, StreamExt};
22+
use indexmap::IndexMap;
23+
use monero_serai::{
24+
block::{Block, BlockHeader},
25+
transaction::{Input, Timelock, Transaction, TransactionPrefix},
26+
};
27+
use proptest::{collection::vec, prelude::*};
28+
use tokio::sync::mpsc;
29+
use tokio::time::timeout;
30+
use tower::buffer::Buffer;
31+
use tower::{service_fn, Service, ServiceExt};
3132

3233
use crate::{
3334
block_downloader::{download_blocks, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse},
34-
client_pool::ClientPool,
35+
peer_set::PeerSet,
3536
};
3637

3738
proptest! {
@@ -51,16 +52,18 @@ proptest! {
5152
#[expect(clippy::significant_drop_tightening)]
5253
tokio_pool.block_on(async move {
5354
timeout(Duration::from_secs(600), async move {
54-
let client_pool = ClientPool::new();
55+
let (new_connection_tx, new_connection_rx) = mpsc::channel(peers);
56+
57+
let peer_set = PeerSet::new(new_connection_rx);
5558

5659
for _ in 0..peers {
5760
let client = mock_block_downloader_client(Arc::clone(&blockchain));
5861

59-
client_pool.add_new_client(client);
62+
new_connection_tx.try_send(client).unwrap();
6063
}
6164

6265
let stream = download_blocks(
63-
client_pool,
66+
Buffer::new(peer_set, 10).boxed_clone(),
6467
OurChainSvc {
6568
genesis: *blockchain.blocks.first().unwrap().0
6669
},

p2p/p2p/src/peer_set.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use cuprate_p2p_core::client::{Client, InternalPeerID, WeakClient};
1+
use cuprate_p2p_core::client::{Client, InternalPeerID};
22
use cuprate_p2p_core::NetworkZone;
33
use indexmap::IndexMap;
44
use std::future::{ready, Ready};
5-
use std::sync::atomic::{AtomicBool, Ordering};
6-
use std::sync::Arc;
75
use std::task::{Context, Poll};
86
use tokio::sync::mpsc;
97
use tower::Service;

p2p/p2p/src/peer_set/client_wrappers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ impl<N: NetworkZone> StoredClient<N> {
3737
}
3838
}
3939

40+
/*
4041
pub(super) fn stem_peer_guard(&self) -> ClientDropGuard<N> {
4142
ClientDropGuard {
4243
client: self.client.downgrade(),
4344
bool: Arc::clone(&self.stem_peer),
4445
}
4546
}
47+
48+
*/
4649
}
4750

4851
pub struct ClientDropGuard<N: NetworkZone> {

0 commit comments

Comments
 (0)