mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 10:36:42 +01:00
sdk: only instantiate caches by default when they are necessary.
This commit is contained in:
@@ -65,22 +65,10 @@ func (rs *RelayStream) Next() string {
|
||||
|
||||
func NewSystem(mods ...SystemModifier) *System {
|
||||
sys := &System{
|
||||
KVStore: kvstore_memory.NewStore(),
|
||||
MetadataCache: cache_memory.New32[ProfileMetadata](8000),
|
||||
RelayListCache: cache_memory.New32[GenericList[Relay]](8000),
|
||||
FollowListCache: cache_memory.New32[GenericList[ProfileRef]](1000),
|
||||
MuteListCache: cache_memory.New32[GenericList[ProfileRef]](1000),
|
||||
BookmarkListCache: cache_memory.New32[GenericList[EventRef]](1000),
|
||||
PinListCache: cache_memory.New32[GenericList[EventRef]](1000),
|
||||
BlockedRelayListCache: cache_memory.New32[GenericList[RelayURL]](1000),
|
||||
SearchRelayListCache: cache_memory.New32[GenericList[RelayURL]](1000),
|
||||
TopicListCache: cache_memory.New32[GenericList[Topic]](1000),
|
||||
RelaySetsCache: cache_memory.New32[GenericSets[RelayURL]](1000),
|
||||
FollowSetsCache: cache_memory.New32[GenericSets[ProfileRef]](1000),
|
||||
TopicSetsCache: cache_memory.New32[GenericSets[Topic]](1000),
|
||||
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"),
|
||||
MetadataRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
||||
KVStore: kvstore_memory.NewStore(),
|
||||
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"),
|
||||
MetadataRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"),
|
||||
FallbackRelays: NewRelayStream(
|
||||
"wss://relay.damus.io",
|
||||
"wss://nostr.mom",
|
||||
@@ -117,6 +105,13 @@ func NewSystem(mods ...SystemModifier) *System {
|
||||
mod(sys)
|
||||
}
|
||||
|
||||
if sys.MetadataCache == nil {
|
||||
sys.MetadataCache = cache_memory.New32[ProfileMetadata](8000)
|
||||
}
|
||||
if sys.RelayListCache == nil {
|
||||
sys.RelayListCache = cache_memory.New32[GenericList[Relay]](8000)
|
||||
}
|
||||
|
||||
if sys.Store == nil {
|
||||
sys.Store = &nullstore.NullStore{}
|
||||
sys.Store.Init()
|
||||
|
||||
Reference in New Issue
Block a user