sdk: a bunch of more list loaders.
This commit is contained in:
+23
-1
@@ -22,6 +22,17 @@ func (sys *System) FetchBookmarkList(ctx context.Context, pubkey nostr.PubKey) G
|
|||||||
return ml
|
return ml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchProfileBadgesList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
|
||||||
|
sys.profileBadgesListCacheOnce.Do(func() {
|
||||||
|
if sys.ProfileBadgesListCache == nil {
|
||||||
|
sys.ProfileBadgesListCache = cache_memory.New[GenericList[string, EventRef]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10008, kind_10008, parseEventRef, sys.ProfileBadgesListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
func (sys *System) FetchPinList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
|
func (sys *System) FetchPinList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
|
||||||
sys.pinListCacheOnce.Do(func() {
|
sys.pinListCacheOnce.Do(func() {
|
||||||
if sys.PinListCache == nil {
|
if sys.PinListCache == nil {
|
||||||
@@ -33,6 +44,17 @@ func (sys *System) FetchPinList(ctx context.Context, pubkey nostr.PubKey) Generi
|
|||||||
return ml
|
return ml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchGitRepositoryList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
|
||||||
|
sys.gitRepositoryListCacheOnce.Do(func() {
|
||||||
|
if sys.GitRepositoryListCache == nil {
|
||||||
|
sys.GitRepositoryListCache = cache_memory.New[GenericList[string, EventRef]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10018, kind_10018, parseEventRef, sys.GitRepositoryListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
func parseEventRef(tag nostr.Tag) (evr EventRef, ok bool) {
|
func parseEventRef(tag nostr.Tag) (evr EventRef, ok bool) {
|
||||||
if len(tag) < 2 {
|
if len(tag) < 2 {
|
||||||
return evr, false
|
return evr, false
|
||||||
@@ -54,5 +76,5 @@ func parseEventRef(tag nostr.Tag) (evr EventRef, ok bool) {
|
|||||||
return evr, false
|
return evr, false
|
||||||
}
|
}
|
||||||
|
|
||||||
return evr, false
|
return evr, true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,39 @@ func (sys *System) FetchMuteList(ctx context.Context, pubkey nostr.PubKey) Gener
|
|||||||
return ml
|
return ml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchMediaFollowList(ctx context.Context, pubkey nostr.PubKey) GenericList[nostr.PubKey, ProfileRef] {
|
||||||
|
sys.mediaFollowListCacheOnce.Do(func() {
|
||||||
|
if sys.MediaFollowListCache == nil {
|
||||||
|
sys.MediaFollowListCache = cache_memory.New[GenericList[nostr.PubKey, ProfileRef]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10020, kind_10020, parseProfileRef, sys.MediaFollowListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchGoodWikiAuthorList(ctx context.Context, pubkey nostr.PubKey) GenericList[nostr.PubKey, ProfileRef] {
|
||||||
|
sys.goodWikiAuthorListCacheOnce.Do(func() {
|
||||||
|
if sys.GoodWikiAuthorListCache == nil {
|
||||||
|
sys.GoodWikiAuthorListCache = cache_memory.New[GenericList[nostr.PubKey, ProfileRef]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10101, kind_10101, parseProfileRef, sys.GoodWikiAuthorListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchGitAuthorList(ctx context.Context, pubkey nostr.PubKey) GenericList[nostr.PubKey, ProfileRef] {
|
||||||
|
sys.gitAuthorListCacheOnce.Do(func() {
|
||||||
|
if sys.GitAuthorListCache == nil {
|
||||||
|
sys.GitAuthorListCache = cache_memory.New[GenericList[nostr.PubKey, ProfileRef]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10017, kind_10017, parseProfileRef, sys.GitAuthorListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
func (sys *System) FetchFollowSets(ctx context.Context, pubkey nostr.PubKey) GenericSets[nostr.PubKey, ProfileRef] {
|
func (sys *System) FetchFollowSets(ctx context.Context, pubkey nostr.PubKey) GenericSets[nostr.PubKey, ProfileRef] {
|
||||||
sys.followSetsCacheOnce.Do(func() {
|
sys.followSetsCacheOnce.Do(func() {
|
||||||
if sys.FollowSetsCache == nil {
|
if sys.FollowSetsCache == nil {
|
||||||
|
|||||||
@@ -46,6 +46,28 @@ func (sys *System) FetchSearchRelayList(ctx context.Context, pubkey nostr.PubKey
|
|||||||
return ml
|
return ml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchDMRelayList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, RelayURL] {
|
||||||
|
sys.dmRelayListCacheOnce.Do(func() {
|
||||||
|
if sys.DMRelayListCache == nil {
|
||||||
|
sys.DMRelayListCache = cache_memory.New[GenericList[string, RelayURL]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10050, kind_10050, parseRelayURL, sys.DMRelayListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sys *System) FetchGoodWikiRelayList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, RelayURL] {
|
||||||
|
sys.goodWikiRelayListCacheOnce.Do(func() {
|
||||||
|
if sys.GoodWikiRelayListCache == nil {
|
||||||
|
sys.GoodWikiRelayListCache = cache_memory.New[GenericList[string, RelayURL]](1000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10102, kind_10102, parseRelayURL, sys.GoodWikiRelayListCache)
|
||||||
|
return ml
|
||||||
|
}
|
||||||
|
|
||||||
func (sys *System) FetchRelaySets(ctx context.Context, pubkey nostr.PubKey) GenericSets[string, RelayURL] {
|
func (sys *System) FetchRelaySets(ctx context.Context, pubkey nostr.PubKey) GenericSets[string, RelayURL] {
|
||||||
sys.relaySetsCacheOnce.Do(func() {
|
sys.relaySetsCacheOnce.Do(func() {
|
||||||
if sys.RelaySetsCache == nil {
|
if sys.RelaySetsCache == nil {
|
||||||
|
|||||||
+20
-10
@@ -22,32 +22,42 @@ const (
|
|||||||
kind_10001 replaceableIndex = 3
|
kind_10001 replaceableIndex = 3
|
||||||
kind_10002 replaceableIndex = 4
|
kind_10002 replaceableIndex = 4
|
||||||
kind_10003 replaceableIndex = 5
|
kind_10003 replaceableIndex = 5
|
||||||
kind_10004 replaceableIndex = 6
|
kind_10006 replaceableIndex = 6
|
||||||
kind_10005 replaceableIndex = 7
|
kind_10007 replaceableIndex = 7
|
||||||
kind_10006 replaceableIndex = 8
|
kind_10015 replaceableIndex = 8
|
||||||
kind_10007 replaceableIndex = 9
|
kind_10019 replaceableIndex = 9
|
||||||
kind_10015 replaceableIndex = 10
|
kind_10030 replaceableIndex = 10
|
||||||
kind_10019 replaceableIndex = 11
|
kind_10008 replaceableIndex = 11
|
||||||
kind_10030 replaceableIndex = 12
|
kind_10017 replaceableIndex = 12
|
||||||
|
kind_10018 replaceableIndex = 13
|
||||||
|
kind_10020 replaceableIndex = 14
|
||||||
|
kind_10050 replaceableIndex = 15
|
||||||
|
kind_10101 replaceableIndex = 16
|
||||||
|
kind_10102 replaceableIndex = 17
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventResult dataloader.Result[*nostr.Event]
|
type EventResult dataloader.Result[*nostr.Event]
|
||||||
|
|
||||||
func (sys *System) initializeReplaceableDataloaders() {
|
func (sys *System) initializeReplaceableDataloaders() {
|
||||||
sys.replaceableLoaders = make([]*dataloader.Loader[nostr.PubKey, nostr.Event], 13)
|
sys.replaceableLoaders = make([]*dataloader.Loader[nostr.PubKey, nostr.Event], 18)
|
||||||
sys.replaceableLoaders[kind_0] = sys.createReplaceableDataloader(0)
|
sys.replaceableLoaders[kind_0] = sys.createReplaceableDataloader(0)
|
||||||
sys.replaceableLoaders[kind_3] = sys.createReplaceableDataloader(3)
|
sys.replaceableLoaders[kind_3] = sys.createReplaceableDataloader(3)
|
||||||
sys.replaceableLoaders[kind_10000] = sys.createReplaceableDataloader(10000)
|
sys.replaceableLoaders[kind_10000] = sys.createReplaceableDataloader(10000)
|
||||||
sys.replaceableLoaders[kind_10001] = sys.createReplaceableDataloader(10001)
|
sys.replaceableLoaders[kind_10001] = sys.createReplaceableDataloader(10001)
|
||||||
sys.replaceableLoaders[kind_10002] = sys.createReplaceableDataloader(10002)
|
sys.replaceableLoaders[kind_10002] = sys.createReplaceableDataloader(10002)
|
||||||
sys.replaceableLoaders[kind_10003] = sys.createReplaceableDataloader(10003)
|
sys.replaceableLoaders[kind_10003] = sys.createReplaceableDataloader(10003)
|
||||||
sys.replaceableLoaders[kind_10004] = sys.createReplaceableDataloader(10004)
|
|
||||||
sys.replaceableLoaders[kind_10005] = sys.createReplaceableDataloader(10005)
|
|
||||||
sys.replaceableLoaders[kind_10006] = sys.createReplaceableDataloader(10006)
|
sys.replaceableLoaders[kind_10006] = sys.createReplaceableDataloader(10006)
|
||||||
sys.replaceableLoaders[kind_10007] = sys.createReplaceableDataloader(10007)
|
sys.replaceableLoaders[kind_10007] = sys.createReplaceableDataloader(10007)
|
||||||
sys.replaceableLoaders[kind_10015] = sys.createReplaceableDataloader(10015)
|
sys.replaceableLoaders[kind_10015] = sys.createReplaceableDataloader(10015)
|
||||||
sys.replaceableLoaders[kind_10019] = sys.createReplaceableDataloader(10019)
|
sys.replaceableLoaders[kind_10019] = sys.createReplaceableDataloader(10019)
|
||||||
sys.replaceableLoaders[kind_10030] = sys.createReplaceableDataloader(10030)
|
sys.replaceableLoaders[kind_10030] = sys.createReplaceableDataloader(10030)
|
||||||
|
sys.replaceableLoaders[kind_10008] = sys.createReplaceableDataloader(10008)
|
||||||
|
sys.replaceableLoaders[kind_10017] = sys.createReplaceableDataloader(10017)
|
||||||
|
sys.replaceableLoaders[kind_10018] = sys.createReplaceableDataloader(10018)
|
||||||
|
sys.replaceableLoaders[kind_10020] = sys.createReplaceableDataloader(10020)
|
||||||
|
sys.replaceableLoaders[kind_10050] = sys.createReplaceableDataloader(10050)
|
||||||
|
sys.replaceableLoaders[kind_10101] = sys.createReplaceableDataloader(10101)
|
||||||
|
sys.replaceableLoaders[kind_10102] = sys.createReplaceableDataloader(10102)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sys *System) createReplaceableDataloader(kind nostr.Kind) *dataloader.Loader[nostr.PubKey, nostr.Event] {
|
func (sys *System) createReplaceableDataloader(kind nostr.Kind) *dataloader.Loader[nostr.PubKey, nostr.Event] {
|
||||||
|
|||||||
+77
-41
@@ -30,47 +30,83 @@ import (
|
|||||||
// default they're set to in-memory stores, but ideally persisteable
|
// default they're set to in-memory stores, but ideally persisteable
|
||||||
// implementations should be given (some alternatives are provided in subpackages).
|
// implementations should be given (some alternatives are provided in subpackages).
|
||||||
type System struct {
|
type System struct {
|
||||||
KVStore kvstore.KVStore
|
KVStore kvstore.KVStore
|
||||||
metadataCacheOnce sync.Once
|
metadataCacheOnce sync.Once
|
||||||
MetadataCache cache.Cache32[ProfileMetadata]
|
MetadataCache cache.Cache32[ProfileMetadata]
|
||||||
relayListCacheOnce sync.Once
|
relayListCacheOnce sync.Once
|
||||||
RelayListCache cache.Cache32[GenericList[string, Relay]]
|
RelayListCache cache.Cache32[GenericList[string, Relay]]
|
||||||
followListCacheOnce sync.Once
|
followListCacheOnce sync.Once
|
||||||
FollowListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
FollowListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
||||||
muteListCacheOnce sync.Once
|
muteListCacheOnce sync.Once
|
||||||
MuteListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
MuteListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
||||||
bookmarkListCacheOnce sync.Once
|
bookmarkListCacheOnce sync.Once
|
||||||
BookmarkListCache cache.Cache32[GenericList[string, EventRef]]
|
BookmarkListCache cache.Cache32[GenericList[string, EventRef]]
|
||||||
pinListCacheOnce sync.Once
|
pinListCacheOnce sync.Once
|
||||||
PinListCache cache.Cache32[GenericList[string, EventRef]]
|
PinListCache cache.Cache32[GenericList[string, EventRef]]
|
||||||
blockedRelayListCacheOnce sync.Once
|
profileBadgesListCacheOnce sync.Once
|
||||||
BlockedRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
ProfileBadgesListCache cache.Cache32[GenericList[string, EventRef]]
|
||||||
searchRelayListCacheOnce sync.Once
|
gitRepositoryListCacheOnce sync.Once
|
||||||
SearchRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
GitRepositoryListCache cache.Cache32[GenericList[string, EventRef]]
|
||||||
topicListCacheOnce sync.Once
|
blockedRelayListCacheOnce sync.Once
|
||||||
TopicListCache cache.Cache32[GenericList[string, Topic]]
|
BlockedRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
||||||
relaySetsCacheOnce sync.Once
|
searchRelayListCacheOnce sync.Once
|
||||||
RelaySetsCache cache.Cache32[GenericSets[string, RelayURL]]
|
SearchRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
||||||
followSetsCacheOnce sync.Once
|
dmRelayListCacheOnce sync.Once
|
||||||
FollowSetsCache cache.Cache32[GenericSets[nostr.PubKey, ProfileRef]]
|
DMRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
||||||
topicSetsCacheOnce sync.Once
|
goodWikiRelayListCacheOnce sync.Once
|
||||||
TopicSetsCache cache.Cache32[GenericSets[string, Topic]]
|
GoodWikiRelayListCache cache.Cache32[GenericList[string, RelayURL]]
|
||||||
zapProviderCacheOnce sync.Once
|
topicListCacheOnce sync.Once
|
||||||
ZapProviderCache cache.Cache32[nostr.PubKey]
|
TopicListCache cache.Cache32[GenericList[string, Topic]]
|
||||||
mintKeysCacheOnce sync.Once
|
mediaFollowListCacheOnce sync.Once
|
||||||
MintKeysCache cache.Cache32[map[uint64]*btcec.PublicKey]
|
MediaFollowListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
||||||
nutZapInfoCacheOnce sync.Once
|
goodWikiAuthorListCacheOnce sync.Once
|
||||||
NutZapInfoCache cache.Cache32[NutZapInfo]
|
GoodWikiAuthorListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
||||||
Hints hints.HintsDB
|
gitAuthorListCacheOnce sync.Once
|
||||||
Pool *nostr.Pool
|
GitAuthorListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
|
||||||
RelayListRelays *RelayStream
|
relaySetsCacheOnce sync.Once
|
||||||
FollowListRelays *RelayStream
|
RelaySetsCache cache.Cache32[GenericSets[string, RelayURL]]
|
||||||
MetadataRelays *RelayStream
|
followSetsCacheOnce sync.Once
|
||||||
FallbackRelays *RelayStream
|
FollowSetsCache cache.Cache32[GenericSets[nostr.PubKey, ProfileRef]]
|
||||||
JustIDRelays *RelayStream
|
topicSetsCacheOnce sync.Once
|
||||||
UserSearchRelays *RelayStream
|
TopicSetsCache cache.Cache32[GenericSets[string, Topic]]
|
||||||
NoteSearchRelays *RelayStream
|
bookmarkSetsCacheOnce sync.Once
|
||||||
Store eventstore.Store
|
BookmarkSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
curationSetsCacheOnce sync.Once
|
||||||
|
CurationSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
videoCurationSetsCacheOnce sync.Once
|
||||||
|
VideoCurationSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
pictureCurationSetsCacheOnce sync.Once
|
||||||
|
PictureCurationSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
kindMuteSetsCacheOnce sync.Once
|
||||||
|
KindMuteSetsCache cache.Cache32[GenericSets[nostr.PubKey, ProfileRef]]
|
||||||
|
badgeSetsCacheOnce sync.Once
|
||||||
|
BadgeSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
releaseArtifactSetsCacheOnce sync.Once
|
||||||
|
ReleaseArtifactSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
appCurationSetsCacheOnce sync.Once
|
||||||
|
AppCurationSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
calendarSetsCacheOnce sync.Once
|
||||||
|
CalendarSetsCache cache.Cache32[GenericSets[string, EventRef]]
|
||||||
|
starterPackSetsCacheOnce sync.Once
|
||||||
|
StarterPackSetsCache cache.Cache32[GenericSets[nostr.PubKey, ProfileRef]]
|
||||||
|
mediaStarterPackSetsCacheOnce sync.Once
|
||||||
|
MediaStarterPackSetsCache cache.Cache32[GenericSets[nostr.PubKey, ProfileRef]]
|
||||||
|
zapProviderCacheOnce sync.Once
|
||||||
|
ZapProviderCache cache.Cache32[nostr.PubKey]
|
||||||
|
mintKeysCacheOnce sync.Once
|
||||||
|
MintKeysCache cache.Cache32[map[uint64]*btcec.PublicKey]
|
||||||
|
nutZapInfoCacheOnce sync.Once
|
||||||
|
NutZapInfoCache cache.Cache32[NutZapInfo]
|
||||||
|
Hints hints.HintsDB
|
||||||
|
Pool *nostr.Pool
|
||||||
|
RelayListRelays *RelayStream
|
||||||
|
FollowListRelays *RelayStream
|
||||||
|
MetadataRelays *RelayStream
|
||||||
|
FallbackRelays *RelayStream
|
||||||
|
JustIDRelays *RelayStream
|
||||||
|
UserSearchRelays *RelayStream
|
||||||
|
NoteSearchRelays *RelayStream
|
||||||
|
Store eventstore.Store
|
||||||
|
|
||||||
Publisher nostr.Publisher
|
Publisher nostr.Publisher
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user