mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Clean up sc-peerset (#9806)
* Clean up sc-peerset * cargo +nightly fmt --all * Nit * Nit * . * Nit * . * Apply suggestions from code review * . * Update client/peerset/src/peersstate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -92,7 +92,7 @@ struct Metrics {
|
||||
|
||||
impl Metrics {
|
||||
fn register(r: &Registry) -> Result<Self, PrometheusError> {
|
||||
Ok(Metrics {
|
||||
Ok(Self {
|
||||
propagated_transactions: register(
|
||||
Counter::new(
|
||||
"sync_propagated_transactions",
|
||||
@@ -133,7 +133,7 @@ pub struct TransactionsHandlerPrototype {
|
||||
impl TransactionsHandlerPrototype {
|
||||
/// Create a new instance.
|
||||
pub fn new(protocol_id: ProtocolId) -> Self {
|
||||
TransactionsHandlerPrototype {
|
||||
Self {
|
||||
protocol_name: Cow::from({
|
||||
let mut proto = String::new();
|
||||
proto.push_str("/");
|
||||
@@ -401,7 +401,7 @@ impl<B: BlockT + 'static, H: ExHashT> TransactionsHandler<B, H> {
|
||||
let hash = self.transaction_pool.hash_of(&t);
|
||||
peer.known_transactions.insert(hash.clone());
|
||||
|
||||
self.service.report_peer(who.clone(), rep::ANY_TRANSACTION);
|
||||
self.service.report_peer(who, rep::ANY_TRANSACTION);
|
||||
|
||||
match self.pending_transactions_peers.entry(hash.clone()) {
|
||||
Entry::Vacant(entry) => {
|
||||
@@ -409,10 +409,10 @@ impl<B: BlockT + 'static, H: ExHashT> TransactionsHandler<B, H> {
|
||||
validation: self.transaction_pool.import(t),
|
||||
tx_hash: hash,
|
||||
});
|
||||
entry.insert(vec![who.clone()]);
|
||||
entry.insert(vec![who]);
|
||||
},
|
||||
Entry::Occupied(mut entry) => {
|
||||
entry.get_mut().push(who.clone());
|
||||
entry.get_mut().push(who);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -468,11 +468,8 @@ impl<B: BlockT + 'static, H: ExHashT> TransactionsHandler<B, H> {
|
||||
propagated_to.entry(hash).or_default().push(who.to_base58());
|
||||
}
|
||||
trace!(target: "sync", "Sending {} transactions to {}", to_send.len(), who);
|
||||
self.service.write_notification(
|
||||
who.clone(),
|
||||
self.protocol_name.clone(),
|
||||
to_send.encode(),
|
||||
);
|
||||
self.service
|
||||
.write_notification(*who, self.protocol_name.clone(), to_send.encode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user