sdk: automatically store replaceable events since we already check the local store for them.

This commit is contained in:
fiatjaf
2025-12-21 22:14:59 -03:00
parent dd6d3c68fb
commit 99197d8321
4 changed files with 14 additions and 1 deletions
+7
View File
@@ -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()))