fix slowness of previous refactors that injected nostr-sdk into this codebase + refactors.

- adjusting many small things related to nostr-sdk usage
- fetching profiles in a smarter way
- decoupling the logic for rendering profile pages from the `grabData`/`getEvent` flow of other event pages.
- incorporating nostr-sdk more holistically, including more hints stuff
- improving nostr-sdk itself after some bugs and weird behaviors observed here
- set up opentelemetry (should probably remove this later)
This commit is contained in:
fiatjaf
2024-08-01 15:24:22 -03:00
parent 289d097078
commit c0004f67a2
19 changed files with 496 additions and 289 deletions

View File

@@ -8,20 +8,15 @@ import (
"time"
"github.com/dgraph-io/badger/v4"
"github.com/fiatjaf/eventstore"
eventstore_badger "github.com/fiatjaf/eventstore/badger"
)
var (
cache = Cache{}
db eventstore.Store = &eventstore_badger.BadgerBackend{}
)
var cache = Cache{}
type Cache struct {
*badger.DB
}
func (c *Cache) initialize() func() {
func (c *Cache) initializeCache() func() {
db, err := badger.Open(badger.DefaultOptions(s.DiskCachePath))
if err != nil {
log.Fatal().Err(err).Str("path", s.DiskCachePath).Msg("failed to open badger")
@@ -40,7 +35,9 @@ func (c *Cache) initialize() func() {
}
}()
return func() { db.Close() }
return func() {
db.Close()
}
}
func (c *Cache) Delete(key string) error {