Skip to content

feat(api): add sort_by=fee to v3 mempool transactions - #2739

Merged
rafa-stacks merged 3 commits into
mainfrom
feat/v3-mempool-sort-by-fee
Nov 2, 2026
Merged

rafa-stacks merged 3 commits into
mainfrom
feat/v3-mempool-sort-by-fee

Conversation

@rafa-stacks

@rafa-stacks rafa-stacks commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Adds sort_by (receipt_time or fee) and order (asc or desc) to GET /extended/v3/mempool/transactions, so pending transactions can be listed by receipt time or total fee in either direction; the default stays newest first. A cursor only pages the sort_by it was returned for, but works in either order.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.41379% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/routes/v3/mempool.ts 93.93% 2 Missing ⚠️
.../1779800000032_mempool-txs-fee-rate-tx-id-index.ts 95.83% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Fee cursors above PostgreSQL’s signed bigint maximum still pass validation and cause HTTP 500 instead of being rejected with HTTP 400.

1 open issue
What changed in this PR

Adds highest-total-fee-first sorting to GET /extended/v3/mempool/transactions, while preserving receipt-time sorting as the default.

Changes:

  • Adds sort_by=fee with order-specific cursors and mismatch validation.
  • Extends keyset pagination and adds a partial index for fee ordering.
  • Tests fee ordering, tie-breaking, pagination, filtering, and invalid parameters.
File Description
tests/​api/​mempool/​mempool-v3.test.ts Tests fee sorting and cursor behavior.
src/​datastore/​v3/​pg-store-v3.ts Supports fee-based ordering and keyset pagination.
src/​api/​schemas/​v3/​params.ts Defines and documents supported sort orders.
src/​api/​schemas/​v3/​cursors.ts Adds the fee-prefixed list cursor format.
src/​api/​routes/​v3/​mempool.ts Accepts sort selection and rejects mismatched cursors.
migrations/​1779800000032_mempool-txs-fee-rate-tx-id-index.ts Adds a partial fee-and-transaction-ID index for pending transactions.

Review effort: Balanced

Comment thread src/api/routes/v3/mempool.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The mempool fee-sorting and pagination changes have no active review issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the mempool sorting and pagination changes.

No open issues 🎉

Review effort: Balanced

@rafa-stacks
rafa-stacks merged commit ad6f53f into main Nov 2, 2026
27 checks passed
@rafa-stacks
rafa-stacks deleted the feat/v3-mempool-sort-by-fee branch November 2, 2026 21:08
@github-project-automation github-project-automation Bot moved this to ✅ Done in API Board Nov 2, 2026

This branch was successfully deployed

1 active deployment
Production — d189d26e Deployed Nov 2, 2026 by rafa-stacks via build-publish #3884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants