PrimalHQ / primal-caching-service

Primal’s caching service for Nostr connects to the specified set of relays, collects all events in real time, stores them locally, and makes them available to nostr clients through a web socket-based API.
https://primal.net
MIT License
85 stars 13 forks source link

What encoding is used for event_ids and author_pubkeys to store them as binary objects? #20

Open AaruBama opened 6 months ago

AaruBama commented 6 months ago

Hi Team,

I'm trying to fetch event ids but querying results in binary form data and I'm not sure how to decode them. Can someone tell me what encoding is used to convert the event_ids into BLOB format.

Also, what is the reason these can't be stored directly as string and are being stored as a blob instead?

pritk commented 6 months ago

hi, BLOB fields contain binary data. for event_id that's 32 bytes. hexadecimal format is two times bigger than binary data format. there are other formats for other purposes too.

AaruBama commented 6 months ago

Can you please confirm the encoding for author_pubkey as well? Thanks.

pritk commented 6 months ago

author_pubkey contains 32 bytes of binary data too.