mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 16:51:03 +00:00
Reduce CPU overhead of gossip (#10859)
This commit is contained in:
@@ -18,19 +18,13 @@
|
||||
|
||||
use crate::{MessageIntent, Network, ValidationResult, Validator, ValidatorContext};
|
||||
|
||||
use ahash::AHashSet;
|
||||
use libp2p::PeerId;
|
||||
use lru::LruCache;
|
||||
use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
|
||||
use sc_network::ObservedRole;
|
||||
use sp_runtime::traits::{Block as BlockT, Hash, HashFor};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{HashMap, HashSet},
|
||||
iter,
|
||||
sync::Arc,
|
||||
time,
|
||||
time::Instant,
|
||||
};
|
||||
use std::{borrow::Cow, collections::HashMap, iter, sync::Arc, time, time::Instant};
|
||||
|
||||
// FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115
|
||||
// NOTE: The current value is adjusted based on largest production network deployment (Kusama) and
|
||||
@@ -56,7 +50,7 @@ mod rep {
|
||||
}
|
||||
|
||||
struct PeerConsensus<H> {
|
||||
known_messages: HashSet<H>,
|
||||
known_messages: AHashSet<H>,
|
||||
}
|
||||
|
||||
/// Topic stream message with sender.
|
||||
@@ -204,7 +198,8 @@ impl<B: BlockT> ConsensusGossip<B> {
|
||||
?role,
|
||||
"Registering peer",
|
||||
);
|
||||
self.peers.insert(who.clone(), PeerConsensus { known_messages: HashSet::new() });
|
||||
self.peers
|
||||
.insert(who.clone(), PeerConsensus { known_messages: Default::default() });
|
||||
|
||||
let validator = self.validator.clone();
|
||||
let mut context = NetworkContext { gossip: self, network };
|
||||
|
||||
Reference in New Issue
Block a user