mirror of
https://github.com/block/buzz.git
synced 2026-11-13 12:51:34 +00:00
Bound discovery without an unsupported owner filter
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -43,6 +43,9 @@ Future<List<AgentDirectoryEntry>> _loadAssistants(
|
||||
final profiles = <String, NostrEvent>{};
|
||||
final seen = <String>{};
|
||||
const pageSize = 100;
|
||||
// The current relay only indexes single-letter NIP-01 tag filters. It
|
||||
// silently drops #auth, so owner-scoped discovery needs relay support.
|
||||
// Until then fail visibly at this bound rather than drain the directory.
|
||||
const maxPages = 10;
|
||||
for (var page = 1; page <= maxPages; page++) {
|
||||
sync.check();
|
||||
@@ -50,11 +53,6 @@ Future<List<AgentDirectoryEntry>> _loadAssistants(
|
||||
NostrFilter(
|
||||
kinds: const [0],
|
||||
authors: pubkey == null ? null : [pubkey],
|
||||
tags: pubkey == null
|
||||
? {
|
||||
'#auth': [sync.pubkey],
|
||||
}
|
||||
: const {},
|
||||
limit: pageSize,
|
||||
extensions: {'page': page},
|
||||
),
|
||||
|
||||
@@ -125,7 +125,7 @@ void main() {
|
||||
expect(relay.requestedPages, [1, 2]);
|
||||
});
|
||||
test(
|
||||
'owner discovery is scoped and bounded even when the relay keeps paging',
|
||||
'directory discovery is bounded even when the relay keeps paging',
|
||||
() async {
|
||||
final repeated = [
|
||||
for (var i = 0; i < 99; i++) profile(agent, ownedBy: owner, time: i),
|
||||
@@ -140,7 +140,7 @@ void main() {
|
||||
);
|
||||
expect(relay.requestedPages.length, 10);
|
||||
for (final filter in relay.requestedTags) {
|
||||
expect(filter['#auth'], [owner.public]);
|
||||
expect(filter.containsKey('#auth'), isFalse);
|
||||
expect(filter['limit'], 100);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user