diff --git a/sdk/list.go b/sdk/list.go index 4e34bcc..0f4ac02 100644 --- a/sdk/list.go +++ b/sdk/list.go @@ -73,6 +73,7 @@ func fetchGenericList[V comparable, I TagItemWithValue[V]]( newV := tryFetchListFromNetwork(ctx, sys, pubkey, replaceableIndex, parseTag) if newV != nil && newV.Event.CreatedAt > v.Event.CreatedAt { v = *newV + sys.Store.ReplaceEvent(*v.Event) } // register this even if we didn't find anything because we tried @@ -93,6 +94,7 @@ func fetchGenericList[V comparable, I TagItemWithValue[V]]( // we'll only save this if we got something which means we found at least one event lastFetchKey := makeLastFetchKey(actualKind, pubkey) sys.KVStore.Set(lastFetchKey, encodeTimestamp(nostr.Now())) + sys.Store.SaveEvent(*v.Event) } // save cache even if we didn't get anything diff --git a/sdk/metadata.go b/sdk/metadata.go index 957b358..f5956a2 100644 --- a/sdk/metadata.go +++ b/sdk/metadata.go @@ -124,6 +124,8 @@ func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey nostr.PubKey newM := sys.tryFetchMetadataFromNetwork(ctx, pubkey) if newM != nil && newM.Event.CreatedAt > pm.Event.CreatedAt { pm = *newM + + sys.Store.ReplaceEvent(*pm.Event) } // even if we didn't find anything register this because we tried @@ -140,6 +142,8 @@ func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey nostr.PubKey if newM := sys.tryFetchMetadataFromNetwork(ctx, pubkey); newM != nil { pm = *newM + sys.Store.SaveEvent(*pm.Event) + // we'll only save this if we got something which means we found at least one event lastFetchKey := makeLastFetchKey(0, pubkey) sys.KVStore.Set(lastFetchKey, encodeTimestamp(nostr.Now())) diff --git a/sdk/set.go b/sdk/set.go index 598d5a4..4d4e09a 100644 --- a/sdk/set.go +++ b/sdk/set.go @@ -63,6 +63,9 @@ func fetchGenericSets[V comparable, I TagItemWithValue[V]]( // unlike for lists, when fetching sets we will blindly trust whatever we get from the network v = *newV + for _, evt := range newV.Events { + sys.Store.ReplaceEvent(evt) + } // even if we didn't find anything register this because we tried // (and we still have the previous event in our local store) @@ -79,6 +82,10 @@ func fetchGenericSets[V comparable, I TagItemWithValue[V]]( if newV := tryFetchSetsFromNetwork(ctx, sys, pubkey, addressableIndex, parseTag); newV != nil { v = *newV + for _, evt := range newV.Events { + sys.Store.ReplaceEvent(evt) + } + // we'll only save this if we got something which means we found at least one event lastFetchKey := makeLastFetchKey(actualKind, pubkey) sys.KVStore.Set(lastFetchKey, encodeTimestamp(nostr.Now())) diff --git a/sdk/system.go b/sdk/system.go index 1b282fd..30e848c 100644 --- a/sdk/system.go +++ b/sdk/system.go @@ -93,7 +93,7 @@ func (rs *RelayStream) Next() string { func NewSystem() *System { sys := &System{ KVStore: kvstore_memory.NewStore(), - RelayListRelays: NewRelayStream("wss://purplepag.es", "wss://user.kindpag.es", "wss://relay.nos.social"), + RelayListRelays: NewRelayStream("wss://indexer.coracle.social", "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(