sdk: FetchBlossomServerList().

This commit is contained in:
fiatjaf
2026-04-22 15:16:40 -03:00
parent a21ea55eaa
commit 078ee94465
2 changed files with 36 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package sdk
import (
"context"
"fiatjaf.com/nostr"
cache_memory "fiatjaf.com/nostr/sdk/cache/memory"
)
type BlossomURL string
func (r BlossomURL) Value() string { return string(r) }
func (sys *System) FetchBlossomServerList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, BlossomURL] {
sys.blossomServerListCacheOnce.Do(func() {
if sys.BlossomServerListCache == nil {
sys.BlossomServerListCache = cache_memory.New[GenericList[string, BlossomURL]](1000)
}
})
ml, _ := fetchGenericList(sys, ctx, pubkey, 10101, kind_10101, func(t nostr.Tag) (BlossomURL, bool) {
if len(t) < 2 {
return "", false
}
nm, err := nostr.NormalizeHTTPURL(t[1])
if err != nil {
return "", false
}
return BlossomURL(nm), true
}, sys.BlossomServerListCache)
return ml
}
+2
View File
@@ -61,6 +61,8 @@ type System struct {
MediaFollowListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
goodWikiAuthorListCacheOnce sync.Once
GoodWikiAuthorListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
blossomServerListCacheOnce sync.Once
BlossomServerListCache cache.Cache32[GenericList[string, BlossomURL]]
gitAuthorListCacheOnce sync.Once
GitAuthorListCache cache.Cache32[GenericList[nostr.PubKey, ProfileRef]]
relaySetsCacheOnce sync.Once