Skip to content

Commit aa2b058

Browse files
committed
fix: improve api
1 parent ddfd40e commit aa2b058

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

bin/portal-bridge/src/census/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ impl Census {
6969
}
7070

7171
/// Selects peers to receive content.
72-
pub fn select_peers<TContentKey: OverlayContentKey>(
72+
pub fn select_peers(
7373
&self,
7474
subnetwork: Subnetwork,
75-
content_key: &TContentKey,
75+
content_key: &impl OverlayContentKey,
7676
) -> Result<Vec<PeerInfo>, CensusError> {
7777
match subnetwork {
7878
Subnetwork::History => self.history.select_peers(content_key),

bin/portal-bridge/src/census/network.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ impl Network {
106106
}
107107

108108
/// Selects peers to receive content.
109-
pub fn select_peers<TContentKey: OverlayContentKey>(
109+
pub fn select_peers(
110110
&self,
111-
content_key: &TContentKey,
111+
content_key: &impl OverlayContentKey,
112112
) -> Result<Vec<PeerInfo>, CensusError> {
113113
if self.peers.is_empty() {
114114
error!(

bin/portal-bridge/src/census/peer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ impl Peer {
7575
}
7676

7777
/// Returns true if content is within radius.
78-
pub fn is_interested_in_content<TContentKey: OverlayContentKey>(
78+
pub fn is_interested_in_content(
7979
&self,
80-
content_key: &TContentKey,
80+
content_key: &impl OverlayContentKey,
8181
content_id: &[u8; 32],
8282
) -> bool {
8383
if content_key.affected_by_radius() {

bin/portal-bridge/src/census/peers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ impl<W: Weight> Peers<W> {
123123
}
124124

125125
/// Selects peers to receive content.
126-
pub fn select_peers<TContentKey: OverlayContentKey>(
126+
pub fn select_peers(
127127
&self,
128-
content_key: &TContentKey,
128+
content_key: &impl OverlayContentKey,
129129
) -> Vec<PeerInfo> {
130130
self.selector
131131
.select_peers(content_key, self.read().peers.values())

bin/portal-bridge/src/census/scoring.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ use super::peer::{Peer, PeerInfo};
1111

1212
/// A trait for calculating peer's weight.
1313
pub trait Weight: Send + Sync {
14-
fn weight<TContentKey: OverlayContentKey>(
14+
fn weight(
1515
&self,
16-
content_key: &TContentKey,
16+
content_key: &impl OverlayContentKey,
1717
content_id: &[u8; 32],
1818
peer: &Peer,
1919
) -> u32;
2020

21-
fn weight_all<'a, TContentKey: OverlayContentKey>(
21+
fn weight_all<'a>(
2222
&self,
23-
content_key: &TContentKey,
23+
content_key: &impl OverlayContentKey,
2424
peers: impl IntoIterator<Item = &'a Peer>,
2525
) -> impl Iterator<Item = (&'a Peer, u32)> {
2626
let content_id = content_key.content_id();
@@ -81,9 +81,9 @@ impl Default for AdditiveWeight {
8181
}
8282

8383
impl Weight for AdditiveWeight {
84-
fn weight<TContentKey: OverlayContentKey>(
84+
fn weight(
8585
&self,
86-
content_key: &TContentKey,
86+
content_key: &impl OverlayContentKey,
8787
content_id: &[u8; 32],
8888
peer: &Peer,
8989
) -> u32 {
@@ -143,9 +143,9 @@ impl<W: Weight> PeerSelector<W> {
143143
}
144144

145145
/// Selects up to `self.limit` peers based on their weights.
146-
pub fn select_peers<'a, TContentKey: OverlayContentKey>(
146+
pub fn select_peers<'a>(
147147
&self,
148-
content_key: &TContentKey,
148+
content_key: &impl OverlayContentKey,
149149
peers: impl IntoIterator<Item = &'a Peer>,
150150
) -> Vec<PeerInfo> {
151151
let weighted_peers = self

0 commit comments

Comments
 (0)