Repository navigation
Filter hardware offers and add bounded marketplace pages - #34
Conversation
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
NetworkTheoryAppliedResearchInstitute
left a comment
There was a problem hiding this comment.
Thanks, Nirmal. This is a careful, well-documented change.
What I tested: PR head 4c94728, via merge ref ca74c9d, which sits on current main 5cc982c.
- CI passed gofmt, vet, build and
go test ./...(18 packages ok, 0 failures, the same as main). DCO passes. - I read the code against the docs. I also ran a line-for-line port of
Browsethrough a random property check: 20,000 logs, 37,970 pages, with new entries appended between pages. Every match came back exactly once, in append order, and no page went over its limit. - Input checks, last-page handling and the limits the docs state all match the code. The listing view still has the same nine fields.
Nothing blocking. A few small items, fine as a quick extra commit or a follow-up:
internal/consumerapi/market_browse_test.go:117checks that the row has 9 fields, but the comment at :99-100 anddocs/marketplace-browse.md:87say it checks the exact fields. Compare the sorted keys with the nine expected names, or reword the docs.market_browse_test.go:152:maker=aa&maker=bbgets a 400 becauseaais not a valid key, so it would still pass without the repeat check atmarket_query.go:19. Use two valid 64-hex keys, e.g.strings.Repeat("ab", 32)andstrings.Repeat("cd", 32).market_browse_test.go:176-177: nothing checksnext_cursoron a cursor-only request. Asserting"50"forcursor=0and"100"forlimit=100would pin the cursor-only rule from the docs.docs/marketplace-browse.md:36: the example{"listings": [], "next_cursor": "125"}can't happen, becausenext_cursoronly comes with a full page. Showing[...]there would match the code.- Cursors across a restart (
internal/market/browse.go:32,server.go:254): once the new in-memory log grows past an old cursor, that cursor returns 200 and skips the earlier offers without an error. Tying the cursor to the instance would let clients notice the restart thatdocs/marketplace-browse.md:49-51mentions: for example, prefix it with an epoch or the log ID and return 400 on a mismatch. - Optional cleanup:
Catalog.ByCategory(catalog.go:154) no longer has a production caller and repeats the category match inBrowse. A thin wrapper overBrowsewould keep one code path. TheSalesOfcomment about the composition root was already out of date before this PR. - Optional wording: at
CONFORMANCE.md:84, the phrase fromdocs/marketplace-browse.md:5-6("Maker keys are the existing platform member keys") reads more clearly than "member identity" next to JFA line 7.
For later, not this PR: requests without limit or cursor are still unbounded. You document this, and this PR shortens how long the lock is held. Making paging the default in a follow-up would close it.
Approved at the tested commit 4c94728 on Jodson Graves's instruction.
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
Signed-off-by: Nirmal Khedkar <nirmalhk7@gmail.com>
NetworkTheoryAppliedResearchInstitute
left a comment
There was a problem hiding this comment.
Thanks, Nirmal. Re-reviewed at c7b0a7f.
What I checked:
- I read the full diff against main and the commits since the 11-04 review (4c94728..c7b0a7f).
- A dry-run merge onto current main is clean.
- I reviewed by reading the code and didn't run it. CI hasn't run on this head yet: runs from a fork wait for a maintainer's OK. This approval holds only if it passes. If anything fails, I'll come back to you.
All seven items from last time are done:
- Exact field names:
internal/consumerapi/market_browse_test.go:101-115. - Two valid repeated maker keys:
market_browse_test.go:170. next_cursorpinned:market_pagination_test.go:21-25.- Exhausted-page example:
docs/marketplace-browse.md:35-39. - Restart: tokens are now
<logID>:<pos>(market.go:164,market_query.go:89-98). A token from another run gets a 400, andmarket_restart_test.gocovers both the restart and malformed tokens. The log ID was already public via/api/v1/drops/log, so nothing new is exposed. Nice. ByCategorynow wrapsbrowse()(internal/market/catalog.go:153-155), and theSalesOfcomment is fixed.- Wording:
CONFORMANCE.md:83-84.
Two optional nits are inline, fine to skip or do later.
For later, not this PR:
- Unpaged reads are still unbounded. That's documented and was deferred in the last review.
- A maker or rail filter with no category returns nothing, so seeing all of one maker's offers takes one call per category.
Heads-up: once this merges, #36 needs a small rebase. Both PRs add a paragraph at the end of the same CONFORMANCE.md section, and keeping both resolves it.
Approved at c7b0a7f on Jodson Graves's instruction, conditional on CI passing on this commit.
| return n, err | ||
| } | ||
|
|
||
| func marketCursorPosition(cursor, instance string) (int, error) { |
There was a problem hiding this comment.
Optional: this check catches stale tokens only because NewServer generates a new operator key on every start (server.go:258, 287), so the log ID changes each run. Could you add a one-line comment saying so? Then if the operator key is ever loaded from disk while the catalogue is still in memory, whoever makes that change will know the tokens need a different per-run value.
| `TestMarketplaceBrowseFilters`, `TestMarketplaceBrowsePagesAcrossSalesAndAppends`, | ||
| `TestMarketplaceBrowseRejectsMalformedFilters`, | ||
| `TestMarketplaceBrowseLegacyAndEmptyCategory`, `TestMarketplaceBrowsePageBounds`, | ||
| and `TestMarketplaceBrowseRejectsCursorFromPreviousInstance`. Continuation tokens |
There was a problem hiding this comment.
Optional: TestMarketplaceBrowseSummaryFields and TestMarketplaceBrowseRejectsMalformedInstanceCursor also bind behavior this section describes, so they're worth listing here too.
8bdbf17
into
NTARI-RAND:main
Marketplace browsing currently filters only by category and returns every matching offer. This adds exact maker-key and declared fiat/member-credit filters to
GET /api/v1/market/listings, plus opt-in bounded pagination. Multiple selected rails match any selected rail; category and maker filters combine with that selection.Supplying
limitorcursorenables pages with a default of 50 offers and a maximum of 100. Append-position cursors skip sale records and remain stable as new entries arrive. Valid existing category-only requests retain their summary fields, ordering, and empty-category behavior. Malformed filters, duplicate singleton parameters, and invalid bounds return HTTP 400, including invalid nonempty categories that previously returned an empty result.Traversal avoids copying the full catalogue, category result set, or sales histories, and responses are written after releasing the store lock. Sparse filters can still scan the remaining history, pages are live rather than frozen snapshots, and legacy unpaged requests remain unbounded. Payment filters describe signed acceptance only; escrow policy and credit-settlement authorization are unchanged. API documentation and conformance bindings describe these boundaries.
Validation: new HTTP regressions failed before implementation and pass with the change. Fresh local marketplace acceptance tests, the full
go test -race ./... -count=1suite,go build ./...,go vet ./..., formatting, and whitespace checks passed. Coverage includes combined filters, dual-rail offers, pagination across sales and appends, malformed queries, page bounds, and legacy responses. Hosted CI and human review remain pending.