mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
common: rename AHashIndexMap to AmortizedIndexMap
This commit is contained in:
parent
9e49cb0bca
commit
5176b18ef9
5 changed files with 15 additions and 14 deletions
|
|
@ -9,7 +9,8 @@ pub mod access_list;
|
||||||
pub mod cpu_pinning;
|
pub mod cpu_pinning;
|
||||||
pub mod privileges;
|
pub mod privileges;
|
||||||
|
|
||||||
pub type AHashIndexMap<K, V> = indexmap_amortized::IndexMap<K, V, RandomState>;
|
/// Amortized IndexMap using AHash hasher
|
||||||
|
pub type AmortizedIndexMap<K, V> = indexmap_amortized::IndexMap<K, V, RandomState>;
|
||||||
|
|
||||||
/// Peer or connection valid until this instant
|
/// Peer or connection valid until this instant
|
||||||
///
|
///
|
||||||
|
|
@ -38,7 +39,7 @@ impl ValidUntil {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn extract_response_peers<K, V, R, F>(
|
pub fn extract_response_peers<K, V, R, F>(
|
||||||
rng: &mut impl Rng,
|
rng: &mut impl Rng,
|
||||||
peer_map: &AHashIndexMap<K, V>,
|
peer_map: &AmortizedIndexMap<K, V>,
|
||||||
max_num_peers_to_take: usize,
|
max_num_peers_to_take: usize,
|
||||||
sender_peer_map_key: K,
|
sender_peer_map_key: K,
|
||||||
peer_conversion_function: F,
|
peer_conversion_function: F,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache};
|
use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache};
|
||||||
use aquatic_common::{AHashIndexMap, CanonicalSocketAddr};
|
use aquatic_common::{AmortizedIndexMap, CanonicalSocketAddr};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use smartstring::{LazyCompact, SmartString};
|
use smartstring::{LazyCompact, SmartString};
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ pub struct PeerMapKey<I: Ip> {
|
||||||
pub ip_or_key: Either<I, SmartString<LazyCompact>>,
|
pub ip_or_key: Either<I, SmartString<LazyCompact>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PeerMap<I> = AHashIndexMap<PeerMapKey<I>, Peer<I>>;
|
pub type PeerMap<I> = AmortizedIndexMap<PeerMapKey<I>, Peer<I>>;
|
||||||
|
|
||||||
pub struct TorrentData<I: Ip> {
|
pub struct TorrentData<I: Ip> {
|
||||||
pub peers: PeerMap<I>,
|
pub peers: PeerMap<I>,
|
||||||
|
|
@ -159,7 +159,7 @@ impl<I: Ip> Default for TorrentData<I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TorrentMap<I> = AHashIndexMap<InfoHash, TorrentData<I>>;
|
pub type TorrentMap<I> = AmortizedIndexMap<InfoHash, TorrentData<I>>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TorrentMaps {
|
pub struct TorrentMaps {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use std::time::Instant;
|
||||||
|
|
||||||
use aquatic_common::access_list::create_access_list_cache;
|
use aquatic_common::access_list::create_access_list_cache;
|
||||||
use aquatic_common::access_list::AccessListArcSwap;
|
use aquatic_common::access_list::AccessListArcSwap;
|
||||||
use aquatic_common::AHashIndexMap;
|
use aquatic_common::AmortizedIndexMap;
|
||||||
use aquatic_common::CanonicalSocketAddr;
|
use aquatic_common::CanonicalSocketAddr;
|
||||||
use aquatic_common::ValidUntil;
|
use aquatic_common::ValidUntil;
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
|
|
@ -39,7 +39,7 @@ impl<I: Ip> Peer<I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeerMap<I> = AHashIndexMap<PeerId, Peer<I>>;
|
type PeerMap<I> = AmortizedIndexMap<PeerId, Peer<I>>;
|
||||||
|
|
||||||
struct TorrentData<I: Ip> {
|
struct TorrentData<I: Ip> {
|
||||||
pub peers: PeerMap<I>,
|
pub peers: PeerMap<I>,
|
||||||
|
|
@ -57,7 +57,7 @@ impl<I: Ip> Default for TorrentData<I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TorrentMap<I> = AHashIndexMap<InfoHash, TorrentData<I>>;
|
type TorrentMap<I> = AmortizedIndexMap<InfoHash, TorrentData<I>>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TorrentMaps {
|
struct TorrentMaps {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use slab::Slab;
|
||||||
use aquatic_common::access_list::create_access_list_cache;
|
use aquatic_common::access_list::create_access_list_cache;
|
||||||
use aquatic_common::access_list::AccessListCache;
|
use aquatic_common::access_list::AccessListCache;
|
||||||
use aquatic_common::ValidUntil;
|
use aquatic_common::ValidUntil;
|
||||||
use aquatic_common::{AHashIndexMap, CanonicalSocketAddr};
|
use aquatic_common::{AmortizedIndexMap, CanonicalSocketAddr};
|
||||||
use aquatic_udp_protocol::*;
|
use aquatic_udp_protocol::*;
|
||||||
use socket2::{Domain, Protocol, Socket, Type};
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ use crate::common::*;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ConnectionMap(AHashIndexMap<(ConnectionId, CanonicalSocketAddr), ValidUntil>);
|
pub struct ConnectionMap(AmortizedIndexMap<(ConnectionId, CanonicalSocketAddr), ValidUntil>);
|
||||||
|
|
||||||
impl ConnectionMap {
|
impl ConnectionMap {
|
||||||
pub fn insert(
|
pub fn insert(
|
||||||
|
|
@ -66,7 +66,7 @@ impl PendingScrapeResponseSlab {
|
||||||
request: ScrapeRequest,
|
request: ScrapeRequest,
|
||||||
valid_until: ValidUntil,
|
valid_until: ValidUntil,
|
||||||
) -> impl IntoIterator<Item = (RequestWorkerIndex, PendingScrapeRequest)> {
|
) -> impl IntoIterator<Item = (RequestWorkerIndex, PendingScrapeRequest)> {
|
||||||
let mut split_requests: AHashIndexMap<RequestWorkerIndex, PendingScrapeRequest> =
|
let mut split_requests: AmortizedIndexMap<RequestWorkerIndex, PendingScrapeRequest> =
|
||||||
Default::default();
|
Default::default();
|
||||||
|
|
||||||
if request.info_hashes.is_empty() {
|
if request.info_hashes.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use glommio::timer::TimerActionRepeat;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use rand::{rngs::SmallRng, SeedableRng};
|
use rand::{rngs::SmallRng, SeedableRng};
|
||||||
|
|
||||||
use aquatic_common::{extract_response_peers, AHashIndexMap};
|
use aquatic_common::{extract_response_peers, AmortizedIndexMap};
|
||||||
use aquatic_ws_protocol::*;
|
use aquatic_ws_protocol::*;
|
||||||
|
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
|
|
@ -49,7 +49,7 @@ struct Peer {
|
||||||
pub valid_until: ValidUntil,
|
pub valid_until: ValidUntil,
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeerMap = AHashIndexMap<PeerId, Peer>;
|
type PeerMap = AmortizedIndexMap<PeerId, Peer>;
|
||||||
|
|
||||||
struct TorrentData {
|
struct TorrentData {
|
||||||
pub peers: PeerMap,
|
pub peers: PeerMap,
|
||||||
|
|
@ -68,7 +68,7 @@ impl Default for TorrentData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TorrentMap = AHashIndexMap<InfoHash, TorrentData>;
|
type TorrentMap = AmortizedIndexMap<InfoHash, TorrentData>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TorrentMaps {
|
struct TorrentMaps {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue