refactor: selectRandomPeer doesn't need to be async

This commit is contained in:
fryorcraken.eth 2022-09-11 09:54:10 +10:00
parent 3b05bfe988
commit 056aed59fb
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 1 additions and 3 deletions

View File

@ -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));