This commit is contained in:
Christien Rioux
2023-09-02 18:50:12 -04:00
parent a77f80a8a9
commit b3354194e0
12 changed files with 70 additions and 161 deletions

View File

@@ -168,9 +168,7 @@ impl ConnectionTable {
};
// Add the connection to the table
let res = inner.conn_by_id[protocol_index].insert(id, network_connection, |_k, _v| {
// never lrus, unbounded
});
let res = inner.conn_by_id[protocol_index].insert(id, network_connection);
assert!(res.is_none());
// if we have reached the maximum number of connections per protocol type

View File

@@ -454,9 +454,7 @@ impl NetworkManager {
pub fn update_client_whitelist(&self, client: TypedKey) {
let mut inner = self.inner.lock();
match inner.client_whitelist.entry(client, |_k, _v| {
// do nothing on LRU evict
}) {
match inner.client_whitelist.entry(client) {
hashlink::lru_cache::Entry::Occupied(mut entry) => {
entry.get_mut().last_seen_ts = get_aligned_timestamp()
}
@@ -472,9 +470,7 @@ impl NetworkManager {
pub fn check_client_whitelist(&self, client: TypedKey) -> bool {
let mut inner = self.inner.lock();
match inner.client_whitelist.entry(client, |_k, _v| {
// do nothing on LRU evict
}) {
match inner.client_whitelist.entry(client) {
hashlink::lru_cache::Entry::Occupied(mut entry) => {
entry.get_mut().last_seen_ts = get_aligned_timestamp();
true

View File

@@ -461,7 +461,7 @@ impl NetworkManager {
self.inner
.lock()
.node_contact_method_cache
.insert(ncm_key, ncm.clone(), |_, _| {});
.insert(ncm_key, ncm.clone());
Ok(ncm)
}

View File

@@ -45,9 +45,7 @@ impl NetworkManager {
inner
.stats
.per_address_stats
.entry(PerAddressStatsKey(addr), |_k, _v| {
// do nothing on LRU evict
})
.entry(PerAddressStatsKey(addr))
.or_insert(PerAddressStats::default())
.transfer_stats_accounting
.add_up(bytes);
@@ -63,9 +61,7 @@ impl NetworkManager {
inner
.stats
.per_address_stats
.entry(PerAddressStatsKey(addr), |_k, _v| {
// do nothing on LRU evict
})
.entry(PerAddressStatsKey(addr))
.or_insert(PerAddressStats::default())
.transfer_stats_accounting
.add_down(bytes);

View File

@@ -117,9 +117,7 @@ impl NetworkManager {
.public_address_check_cache
.entry(addr_proto_type_key)
.or_insert_with(|| LruCache::new(PUBLIC_ADDRESS_CHECK_CACHE_SIZE));
pacc.insert(ipblock, socket_address, |_k, _v| {
// do nothing on LRU evict
});
pacc.insert(ipblock, socket_address);
// Determine if our external address has likely changed
let mut bad_public_address_detection_punishment: Option<