mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
bencher: change to account for new aquatic_udp implementation
This commit is contained in:
parent
358c8951c0
commit
2c7bcf71ad
4 changed files with 33 additions and 36 deletions
|
|
@ -16,6 +16,7 @@ use aquatic_common::{CanonicalSocketAddr, IndexMap};
|
|||
use aquatic_udp_protocol::*;
|
||||
use arrayvec::ArrayVec;
|
||||
use crossbeam_channel::Sender;
|
||||
use hashbrown::HashMap;
|
||||
use hdrhistogram::Histogram;
|
||||
use parking_lot::RwLockUpgradableReadGuard;
|
||||
use rand::prelude::SmallRng;
|
||||
|
|
@ -29,24 +30,24 @@ const SMALL_PEER_MAP_CAPACITY: usize = 2;
|
|||
use aquatic_udp_protocol::InfoHash;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
type TorrentMapShard<T> = IndexMap<InfoHash, Arc<TorrentData<T>>>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TorrentMaps {
|
||||
ipv4: TorrentMapShards<Ipv4AddrBytes>,
|
||||
ipv6: TorrentMapShards<Ipv6AddrBytes>,
|
||||
}
|
||||
|
||||
impl TorrentMaps {
|
||||
pub fn new(config: &Config) -> Self {
|
||||
let num_shards = 16usize;
|
||||
impl Default for TorrentMaps {
|
||||
fn default() -> Self {
|
||||
const NUM_SHARDS: usize = 16;
|
||||
|
||||
Self {
|
||||
ipv4: TorrentMapShards::new(num_shards),
|
||||
ipv6: TorrentMapShards::new(num_shards),
|
||||
ipv4: TorrentMapShards::new(NUM_SHARDS),
|
||||
ipv6: TorrentMapShards::new(NUM_SHARDS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TorrentMaps {
|
||||
pub fn announce(
|
||||
&self,
|
||||
config: &Config,
|
||||
|
|
@ -294,6 +295,9 @@ impl<I: Ip> TorrentMapShards<I> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Use HashMap instead of IndexMap for better lookup performance
|
||||
type TorrentMapShard<T> = HashMap<InfoHash, Arc<TorrentData<T>>>;
|
||||
|
||||
pub struct TorrentData<T: Ip> {
|
||||
peer_map: RwLock<PeerMap<T>>,
|
||||
pending_removal: AtomicBool,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue