Fully rewrite relay

This commit is contained in:
Danny Morabito 2025-06-04 12:43:23 +02:00
parent 190e38dfc1
commit 20ffbd4c6d
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 7CC8056A5A04557E
47 changed files with 3489 additions and 128 deletions

39
src/relays.ts Normal file
View file

@ -0,0 +1,39 @@
import * as nostrTools from '@nostr/tools';
import { isArray } from './utils/isArray.ts';
export const pool = new nostrTools.SimplePool();
export const relays = [
'wss://relay.arx-ccn.com/',
'wss://relay.dannymorabito.com/',
'wss://nos.lol/',
'wss://nostr.einundzwanzig.space/',
'wss://nostr.massmux.com/',
'wss://nostr.mom/',
'wss://nostr.wine/',
'wss://purplerelay.com/',
'wss://relay.damus.io/',
'wss://relay.goodmorningbitcoin.com/',
'wss://relay.lexingtonbitcoin.org/',
'wss://relay.nostr.band/',
'wss://relay.primal.net/',
'wss://relay.snort.social/',
'wss://strfry.iris.to/',
'wss://cache2.primal.net/v1',
];
/**
* FIXME: make sure to somehow tag encryptedEvents and add asserts, so that it's not possible to accidentally call this function with unencrypted events
*
* @param encryptedEvent the event to publish to the relay
*/
export async function publishToRelays(
encryptedEvent: nostrTools.Event | nostrTools.Event[],
): Promise<void> {
if (isArray(encryptedEvent)) {
for (const chunk of encryptedEvent) {
await Promise.any(pool.publish(relays, chunk));
}
} else {
await Promise.any(pool.publish(relays, encryptedEvent));
}
}