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

Fetching from DB kills the process and makes system unresponsive. #19

Closed AaruBama closed 6 months ago

AaruBama commented 7 months ago

Hello Team, Thank you so much for creating such a wonderful project. It works well and fetches data correctly and dumps them into sqlite as expected but there are a few challenges I'm facing while trying to incorporate the system.

pritk commented 7 months ago

for example, in julia REPL:

eid=Nostr.bech32_decode("note193krlw8navg52aetpmgsju5y4lcrcrp638gjdvmal7rfz6pacgmqnlh9qq")
App.event_stats(cache_storage, eid)

output:

1-element Vector{NamedTuple{(:kind, :content), Tuple{Int64, String}}}:
 (kind = 10000100, content = "{\"event_id\":\"2c6c3fb8f3eb1145772b0ed1097284aff03c0c3a89d126b37dff8691683dc236\",\"likes\":0,\"replies\":0,\"mentions\":0,\"reposts\":0,\"zaps\":0,\"satszapped\":0,\"score\":0,\"score24h\":0}")
AaruBama commented 7 months ago

Thank you. It worked. I was instantiating a DB.CacheStorage each time not knowing i could just use cache_storage directly. Your clarification and example worked smoothly. :bow: :+1:

Just one more question before I can close it off. How are score and score_24h calculated. I tried reading julia but i keep moving in between functions due to my limited knowledge of jl. Thanks.

pritk commented 7 months ago

that functionality is in different repo:

https://github.com/PrimalHQ/primal-server/blob/3094b8556423f54d98381efce8f4c5c6aa7f1e7e/ext/DB.jl#L482-L491