define a nostr.Kind type for event kinds, make adjustments everywhere and fix some horrible bugs with mmm, lmdb and badger querying and deleting.

This commit is contained in:
fiatjaf
2025-04-20 11:14:39 -03:00
parent 27f40c2cf2
commit 15c6093c9b
74 changed files with 689 additions and 404 deletions

View File

@@ -28,7 +28,7 @@ func (sys *System) initializeAddressableDataloaders() {
sys.addressableLoaders[kind_30030] = sys.createAddressableDataloader(30030)
}
func (sys *System) createAddressableDataloader(kind uint16) *dataloader.Loader[nostr.PubKey, []nostr.Event] {
func (sys *System) createAddressableDataloader(kind nostr.Kind) *dataloader.Loader[nostr.PubKey, []nostr.Event] {
return dataloader.NewBatchedLoader(
func(ctxs []context.Context, pubkeys []nostr.PubKey) map[nostr.PubKey]dataloader.Result[[]nostr.Event] {
return sys.batchLoadAddressableEvents(ctxs, kind, pubkeys)
@@ -42,7 +42,7 @@ func (sys *System) createAddressableDataloader(kind uint16) *dataloader.Loader[n
func (sys *System) batchLoadAddressableEvents(
ctxs []context.Context,
kind uint16,
kind nostr.Kind,
pubkeys []nostr.PubKey,
) map[nostr.PubKey]dataloader.Result[[]nostr.Event] {
batchSize := len(pubkeys)
@@ -77,7 +77,7 @@ func (sys *System) batchLoadAddressableEvents(
dfilter = nostr.DirectedFilter{
Relay: relay,
Filter: nostr.Filter{
Kinds: []uint16{kind},
Kinds: []nostr.Kind{kind},
Authors: make([]nostr.PubKey, 0, batchSize-i /* this and all pubkeys after this can be added */),
},
}