eventstore: QueryEvents() to take a maxLimit param now so everything is clearer.
This commit is contained in:
@@ -124,19 +124,18 @@ func (sys *System) FetchFeedPage(
|
||||
}
|
||||
|
||||
filter := nostr.Filter{Authors: []nostr.PubKey{pubkey}, Kinds: kinds}
|
||||
|
||||
if until > oldestTimestamp {
|
||||
// we can use our local database
|
||||
filter.Until = until
|
||||
|
||||
count := 0
|
||||
for evt := range sys.Store.QueryEvents(filter) {
|
||||
for evt := range sys.Store.QueryEvents(filter, limitPerKey) {
|
||||
events = append(events, evt)
|
||||
count++
|
||||
if count >= limitPerKey {
|
||||
// we got enough from the local store
|
||||
wg.Done()
|
||||
continue
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestStreamLiveFeed(t *testing.T) {
|
||||
for _, r := range []*khatru.Relay{relay1, relay2, relay3} {
|
||||
db := &slicestore.SliceStore{}
|
||||
db.Init()
|
||||
r.UseEventstore(db)
|
||||
r.UseEventstore(db, 4000)
|
||||
defer db.Close()
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@ func fetchGenericList[V comparable, I TagItemWithValue[V]](
|
||||
|
||||
v := GenericList[V, I]{PubKey: pubkey}
|
||||
|
||||
for evt := range sys.Store.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{actualKind}, Authors: []nostr.PubKey{pubkey}}) {
|
||||
for evt := range sys.Store.QueryEvents(nostr.Filter{
|
||||
Kinds: []nostr.Kind{actualKind},
|
||||
Authors: []nostr.PubKey{pubkey},
|
||||
}, 1) {
|
||||
// ok, we found something locally
|
||||
items := parseItemsFromEventTags(evt, parseTag)
|
||||
v.Event = &evt
|
||||
|
||||
@@ -111,7 +111,7 @@ func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey nostr.PubKey
|
||||
|
||||
pm.PubKey = pubkey
|
||||
|
||||
for evt := range sys.Store.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{0}, Authors: []nostr.PubKey{pubkey}}) {
|
||||
for evt := range sys.Store.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{0}, Authors: []nostr.PubKey{pubkey}}, 1) {
|
||||
// ok, we found something locally
|
||||
pm, _ = ParseMetadata(evt)
|
||||
pm.PubKey = pubkey
|
||||
|
||||
@@ -47,7 +47,7 @@ func fetchGenericSets[V comparable, I TagItemWithValue[V]](
|
||||
v := GenericSets[V, I]{PubKey: pubkey}
|
||||
|
||||
events := slices.Collect(
|
||||
sys.Store.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{actualKind}, Authors: []nostr.PubKey{pubkey}}),
|
||||
sys.Store.QueryEvents(nostr.Filter{Kinds: []nostr.Kind{actualKind}, Authors: []nostr.PubKey{pubkey}}, 100),
|
||||
)
|
||||
if len(events) != 0 {
|
||||
// ok, we found something locally
|
||||
|
||||
@@ -95,7 +95,7 @@ func (sys *System) FetchSpecificEvent(
|
||||
|
||||
// try to fetch in our internal eventstore first
|
||||
if !params.SkipLocalStore {
|
||||
for evt := range sys.Store.QueryEvents(filter) {
|
||||
for evt := range sys.Store.QueryEvents(filter, 1) {
|
||||
return &evt, nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func NewSystem() *System {
|
||||
sys.Store = &nullstore.NullStore{}
|
||||
sys.Store.Init()
|
||||
}
|
||||
sys.Publisher = wrappers.StorePublisher{Store: sys.Store}
|
||||
sys.Publisher = wrappers.StorePublisher{Store: sys.Store, MaxLimit: 1000}
|
||||
|
||||
sys.initializeReplaceableDataloaders()
|
||||
sys.initializeAddressableDataloaders()
|
||||
|
||||
Reference in New Issue
Block a user