From d6fb438ea069103e1776ccad3f42a1e86d18526d Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Wed, 8 Mar 2023 16:11:27 -0600 Subject: [PATCH] Stop shuffling relays in sampleRelays --- ROADMAP.md | 3 --- src/agent/relays.ts | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index bc06117f..520c4ee5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,9 +1,6 @@ # Current -- [ ] Collapse relaycard and relaycardsimple? - [ ] Create my own version of nostr.how and extension explanation - -- [ ] Review sampleRelays, seems like we shouldn't be shuffling - [ ] Go over onboarding process, suggest some good relays for newcomers - [ ] Submit blog post with new onboarding process built in - [ ] Fix hover on notes in modal diff --git a/src/agent/relays.ts b/src/agent/relays.ts index d318ae4a..f584ce62 100644 --- a/src/agent/relays.ts +++ b/src/agent/relays.ts @@ -155,10 +155,10 @@ export const sampleRelays = (relays, scale = 1) => { } // Remove relays that are currently in an error state - relays => relays.filter(r => pool.getConnection(r.url)?.hasRecentError()) + relays = relays.filter(r => pool.getConnection(r.url)?.hasRecentError()) - // Shuffle and limit target relays - relays = shuffle(relays).slice(0, limit) + // Limit target relays + relays = relays.slice(0, limit) // If we're still under the limit, add user relays for good measure if (relays.length < limit) { @@ -180,7 +180,7 @@ export const aggregateScores = relayGroups => { for (const relays of relayGroups) { for (const relay of relays) { - const {url, score} = relay + const {url, score = 0.5} = relay if (!scores[url]) { scores[url] = {score: 0, count: 0}