mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-15 10:26:46 +02:00
sdk: mutelist cache.
This commit is contained in:
@@ -5,6 +5,6 @@ import "context"
|
|||||||
type MuteList = GenericList[Follow]
|
type MuteList = GenericList[Follow]
|
||||||
|
|
||||||
func (sys *System) FetchMuteList(ctx context.Context, pubkey string) MuteList {
|
func (sys *System) FetchMuteList(ctx context.Context, pubkey string) MuteList {
|
||||||
ml, _ := fetchGenericList[Follow](sys, ctx, pubkey, 10000, parseFollow, nil, false)
|
ml, _ := fetchGenericList(sys, ctx, pubkey, 10000, parseFollow, sys.MuteListCache, false)
|
||||||
return ml
|
return ml
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ import (
|
|||||||
type System struct {
|
type System struct {
|
||||||
RelayListCache cache.Cache32[RelayList]
|
RelayListCache cache.Cache32[RelayList]
|
||||||
FollowListCache cache.Cache32[FollowList]
|
FollowListCache cache.Cache32[FollowList]
|
||||||
|
MuteListCache cache.Cache32[FollowList]
|
||||||
MetadataCache cache.Cache32[ProfileMetadata]
|
MetadataCache cache.Cache32[ProfileMetadata]
|
||||||
Hints hints.HintsDB
|
Hints hints.HintsDB
|
||||||
Pool *nostr.SimplePool
|
Pool *nostr.SimplePool
|
||||||
@@ -54,6 +55,7 @@ func NewSystem(mods ...SystemModifier) *System {
|
|||||||
sys := &System{
|
sys := &System{
|
||||||
RelayListCache: cache_memory.New32[RelayList](1000),
|
RelayListCache: cache_memory.New32[RelayList](1000),
|
||||||
FollowListCache: cache_memory.New32[FollowList](1000),
|
FollowListCache: cache_memory.New32[FollowList](1000),
|
||||||
|
MuteListCache: cache_memory.New32[FollowList](1000),
|
||||||
MetadataCache: cache_memory.New32[ProfileMetadata](1000),
|
MetadataCache: cache_memory.New32[ProfileMetadata](1000),
|
||||||
RelayListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
RelayListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
||||||
FollowListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
FollowListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
||||||
@@ -173,6 +175,12 @@ func WithFollowListCache(cache cache.Cache32[FollowList]) SystemModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithMuteListCache(cache cache.Cache32[FollowList]) SystemModifier {
|
||||||
|
return func(sys *System) {
|
||||||
|
sys.MuteListCache = cache
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier {
|
func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier {
|
||||||
return func(sys *System) {
|
return func(sys *System) {
|
||||||
sys.MetadataCache = cache
|
sys.MetadataCache = cache
|
||||||
|
Reference in New Issue
Block a user