mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-03 14:23:12 +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.
|
||||
* Useful for protocols such as store and light push
|
||||
*/
|
||||
export async function selectRandomPeer(
|
||||
peers: Peer[]
|
||||
): Promise<Peer | undefined> {
|
||||
export function selectRandomPeer(peers: Peer[]): Peer | undefined {
|
||||
if (peers.length === 0) return;
|
||||
|
||||
const index = Math.round(Math.random() * (peers.length - 1));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user