✨ Fully rewrite relay
This commit is contained in:
parent
190e38dfc1
commit
20ffbd4c6d
47 changed files with 3489 additions and 128 deletions
39
src/relays.ts
Normal file
39
src/relays.ts
Normal 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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue