mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-10 03:24:37 +00:00
refactor: selectRandomPeer doesn't need to be async
This commit is contained in:
parent
3b05bfe988
commit
056aed59fb
@ -4,9 +4,7 @@ import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
|||||||
* Returns a pseudo-random peer that supports the given protocol.
|
* Returns a pseudo-random peer that supports the given protocol.
|
||||||
* Useful for protocols such as store and light push
|
* Useful for protocols such as store and light push
|
||||||
*/
|
*/
|
||||||
export async function selectRandomPeer(
|
export function selectRandomPeer(peers: Peer[]): Peer | undefined {
|
||||||
peers: Peer[]
|
|
||||||
): Promise<Peer | undefined> {
|
|
||||||
if (peers.length === 0) return;
|
if (peers.length === 0) return;
|
||||||
|
|
||||||
const index = Math.round(Math.random() * (peers.length - 1));
|
const index = Math.round(Math.random() * (peers.length - 1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user