Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
  • Loading branch information
sandreim committed Aug 28, 2023
1 parent 0ffbd54 commit da77306
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions polkadot/node/subsystem-util/src/reputation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ impl ReputationAggregator {

fn add(&mut self, peer_id: PeerId, rep: UnifiedReputationChange) {
let cost = rep.cost_or_benefit();
self.by_peer
.get_or_insert(HashMap::new())
.entry(peer_id)
.and_modify(|v| *v = v.saturating_add(cost))
.or_insert(cost);
let by_peer = self.by_peer.get_or_insert(HashMap::new());
add_reputation(by_peer, peer_id, rep)
}
}

/// Add a reputation change to an existing collection.
pub fn add_reputation(
acc: &mut BatchReputationChange,
peer_id: PeerId,
rep: UnifiedReputationChange,
) {
let cost = rep.cost_or_benefit();
acc.entry(peer_id).and_modify(|v| *v = v.saturating_add(cost)).or_insert(cost);
}

0 comments on commit da77306

Please sign in to comment.