useEventList()/useMetadataList() send a REQ that can only return nothing for an empty input
- Ngôn ngữ chính
- TypeScript
- Star
- 29
- Fork
- 3
- Merge trung bình
- 3 giờ 5 phút
- Pull request đã merge (30 ngày)
- 11
Mô tả
Two hooks derive `limit` from the length of their input array:
- `src/lib/stores/useEventList.ts:21` — `{ ids, limit: ids.length }`
- `src/lib/stores/useMetadataList.ts:21` — `{ kinds: [0], authors: pubkeys, limit: pubkeys.length }`
Given an empty array this sends `["REQ", subId, {"ids":[],"limit":0}]`.
rx-nostr's `normalizeFilter` keeps `limit: 0` (`rx-req.ts:229`), and `use()`'s
guard `filter(({ filters }) => filters.length > 0)` counts *filters*, not ids, so
the REQ goes out to every relay. It can only ever return nothing.
An empty input is a normal thing for a caller to hold briefly — an id list derived
from another query that has not resolved yet, or a contact list that is still
loading.
Determined by code reading, with the `normalizeFilter` behaviour checked in the
installed rx-nostr source.
## Direction
Short-circuit on an empty input: return the empty result without sending a REQ.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Start with src/lib/stores/useEventList.ts and src/lib/stores/useMetadataList.ts at the lines deriving limit from the input array length. Check how each hook calls use() and add an empty-input path that returns the empty result instead of sending a REQ. Done means empty ids or pubkeys do not produce a relay request.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- frontend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 76/100