ndk icon indicating copy to clipboard operation
ndk copied to clipboard

create a config to include readonly relay (caching relay)

Open antonioconselheiro opened this issue 2 years ago • 4 comments

this will allow to integrate with cache relays like https://github.com/PrimalHQ/primal-caching-service, they don't receive publish, it just cache data from other relays.

Suggestion:

const ndk = new NDK({
    explicitRelayUrls: ["wss://a.relay", "wss://another.relay"],
    explicitReadonlyRelayUrls: [ "wss://caching.relay" ]
});```

or

```typescript
const ndk = new NDK({
    explicitRelayUrls: ["wss://a.relay", "wss://another.relay"],
    explicitCachingRelayUrls: [ "wss://caching.relay" ]
});```

antonioconselheiro avatar Nov 13 '23 17:11 antonioconselheiro

This makes a lot of sense, I would also need it!

WvFResearch avatar Nov 13 '23 17:11 WvFResearch

It does make sense, but I think this is a hack because relays are not able to communicate these things in the protocol; not sure what to do here because I really want to fix the spec but that's going to take some time.

pablof7z avatar Nov 24 '23 00:11 pablof7z

I'm inclined to think it's worth adding something like this; I'll think about it some more and how to structure it properly

pablof7z avatar Nov 24 '23 00:11 pablof7z

This configuration should create a relay pool that does not write events, read only, where is the hack?

With this, you can allow your user to configure cache services or home cache service actively persisting relay events of interest to us to don't need to connect to anything when I wanna read my timeline.

The protocol is guaranteed by the signature in the event, not by the relay's structure. I can save a signed nostr event in a QR code or in a file, the nsec signature guarantees guarantees the authorship of the event.

The fact that events are shared with event type 6 already allows us to pass events from relay to relay and having these caching services will increase resilience against censorship, which is the fundamental proposal of nostr.

Check primal, it uses cache services: image

This configuration significantly affects the user experience in a positive way, check https://primal.net/.

antonioconselheiro avatar Nov 24 '23 13:11 antonioconselheiro