fix: manage pending relay connection requests #159
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "reduce-relay-connection-attempts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Also remove the getMostPopularRelays function and use a hardcoded list of relays
Further, if metadata event is not found from relays cache an empty metadata for that pubkey
@ -15,3 +14,2 @@
*/
export const ONE_WEEK_IN_MS: number = 604800000
export const SIGIT_RELAY: string = 'wss://relay.sigit.io'
export const ONE_WEEK_IN_MS = 7 * 24 * 60 * 60 * 1000
Why do you need to calculate this constant instead of providing a defined value?
I guess this avoids any uncertainty about how the number was calculated, or if it was calculated correctly. It's a one time operation right?
yes, its one time.
@ -132,3 +118,3 @@
if (cachedMetadataEvent) {
// Check if the cached metadata is older than one week
if (isOlderThanOneWeek(cachedMetadataEvent.cachedAt)) {
if (isOlderThanOneDay(cachedMetadataEvent.cachedAt)) {
There is a discrepancy between the function name and the comments around it. Should it be older than one week or one day?
fixed, Updated comment
@ -196,6 +156,7 @@ const getRelayMap = async (
})
Object.keys(relaysMap).forEach((relayUrl) => {
console.log('being called from getRelayMap')
Should this console log be removed?
removed
@ -256,3 +217,3 @@
// If relay map is empty, use most popular relay URIs
if (!relaysToPublish.length) {
relaysToPublish = await getMostPopularRelays()
relaysToPublish = DEFAULT_LOOK_UP_RELAY_LIST
Should
DEFAULT_LOOK_UP_RELAY_LIST
be copied rather than re-assigned?Its fine here because we're not updating the relaysToPublish array after this assignment in this function (which would have caused side effects on DEFAULT_LOOK_UP_RELAY_LIST).
Further I'm handling the case where I need to append the array by copying the array in the relay controller.