mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-11 11:27:03 +00:00
Fix freshness persistence, optimize pubkey loading
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import {get} from "svelte/store"
|
import {get} from "svelte/store"
|
||||||
import {ctx, uniq, sleep, chunk, equals, choice} from "@welshman/lib"
|
import {ctx, sample, uniq, sleep, chunk, equals, choice} from "@welshman/lib"
|
||||||
import {
|
import {
|
||||||
DELETE,
|
DELETE,
|
||||||
PROFILE,
|
PROFILE,
|
||||||
@@ -169,16 +169,19 @@ export const loadUserData = (
|
|||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
|
||||||
// Load followed profiles slowly in the background without clogging other stuff up
|
// Load followed profiles slowly in the background without clogging other stuff up. Only use a single
|
||||||
|
// indexer relay to avoid too many redundant validations, which slow things down and eat bandwidth
|
||||||
promise.then(async () => {
|
promise.then(async () => {
|
||||||
for (const pubkeys of chunk(50, getDefaultPubkeys())) {
|
for (const pubkeys of chunk(50, getDefaultPubkeys())) {
|
||||||
await sleep(300)
|
const relays = sample(1, INDEXER_RELAYS)
|
||||||
|
|
||||||
|
await sleep(1000)
|
||||||
|
|
||||||
for (const pubkey of pubkeys) {
|
for (const pubkey of pubkeys) {
|
||||||
loadMembership(pubkey)
|
loadMembership(pubkey, {relays})
|
||||||
loadProfile(pubkey)
|
loadProfile(pubkey, {relays})
|
||||||
loadFollows(pubkey)
|
loadFollows(pubkey, {relays})
|
||||||
loadMutes(pubkey)
|
loadMutes(pubkey, {relays})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
const migrateFreshness = (data: {key: string; value: number}[]) => {
|
const migrateFreshness = (data: {key: string; value: number}[]) => {
|
||||||
const cutoff = ago(HOUR)
|
const cutoff = ago(HOUR)
|
||||||
|
|
||||||
return data.filter(({value}) => value < cutoff)
|
return data.filter(({value}) => value > cutoff)
|
||||||
}
|
}
|
||||||
|
|
||||||
const migratePlaintext = (data: {key: string; value: number}[]) => data.slice(0, 10_000)
|
const migratePlaintext = (data: {key: string; value: number}[]) => data.slice(0, 10_000)
|
||||||
|
|||||||
Reference in New Issue
Block a user