Skip to content

Commit

Permalink
node: Send a flood request to 8 randomly selected peers
Browse files Browse the repository at this point in the history
  • Loading branch information
goshawk-3 committed May 21, 2024
1 parent e29ce2e commit 8370805
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions node/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ mod frame;

const MAX_PENDING_SENDERS: u64 = 1000;

/// Number of alive peers randomly selected which a `flood_request` is sent to
const REDUNDANCY_PEER_COUNT: usize = 8;

type RoutesList<const N: usize> = [Option<AsyncQueue<Message>>; N];
type FilterList<const N: usize> = [Option<BoxedFilter>; N];

Expand Down Expand Up @@ -252,12 +255,15 @@ impl<const N: usize> crate::Network for Kadcast<N> {
},
);

self.broadcast(&Message::new_get_resource(GetResource::new(
msg_inv.clone(),
self.public_addr,
ttl_as_sec,
hops_limit,
)))
self.send_to_alive_peers(
&Message::new_get_resource(GetResource::new(
msg_inv.clone(),
self.public_addr,
ttl_as_sec,
hops_limit / REDUNDANCY_PEER_COUNT as u16,
)),
REDUNDANCY_PEER_COUNT,
)
.await
}

Expand Down

0 comments on commit 8370805

Please sign in to comment.