Fix a few bugs, improve storage adapter

This commit is contained in:
Jon Staab
2024-09-04 15:04:47 -07:00
parent b8e69154af
commit 9b44aac584
8 changed files with 64 additions and 41 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
import {
intersection, first, switcher, throttleWithValue, clamp, last, splitAt, identity, sortBy, uniq, shuffle,
pushToMapKey,
pushToMapKey, now,
} from '@welshman/lib'
import {
Tags, getFilterId, unionFilters, isShareableRelayUrl, isCommunityAddress, isGroupAddress, isContextAddress,
@@ -401,19 +401,19 @@ export const getRelayQuality = (url: string) => {
if (!connection) {
const lastFault = last(recent_errors) || 0
if (recent_errors.filter(n => n > Date.now() - oneHour).length > 10) {
if (recent_errors.filter(n => n > now() - oneHour).length > 10) {
return 0
}
if (recent_errors.filter(n => n > Date.now() - oneDay).length > 50) {
if (recent_errors.filter(n => n > now() - oneDay).length > 50) {
return 0
}
if (recent_errors.filter(n => n > Date.now() - oneWeek).length > 100) {
if (recent_errors.filter(n => n > now() - oneWeek).length > 100) {
return 0
}
return Math.max(0, Math.min(0.5, (Date.now() - oneMinute - lastFault) / oneHour))
return Math.max(0, Math.min(0.5, (now() - oneMinute - lastFault) / oneHour))
}
return switcher(connection.meta.getStatus(), {