Skip to content

[feature]: Refactor ListTxns and/or RangeTransactions for Performance and Clarity with include_unmined #1116

@mohamedawnallah

Description

@mohamedawnallah

Issue Description

The current ListTxns API uses the special range $\mathbf{startHeight=0}$ and $\mathbf{endHeight=-1}$ to implicitly retrieve all transactions, including unmined (mempool) transactions.

This is problematic because:

  1. Performance: Including the constantly changing mempool is an unnecessary performance hit when a user only needs a specific historical block range.
  2. Clarity: The behavior relies on "magic number" range values (the non-descriptive $\mathbf{0}$ and $\mathbf{-1}$ combination) rather than explicit control. Explicit control means using a clear, well-named input (like a dedicated flag) to directly command the desired behavior, making the code's intent immediately obvious.

Proposed Improvement

Refactor the underlying transaction listing method to introduce an explicit boolean flag, such as $\mathbf{include\_unmined}$.

  • This allows users to explicitly opt-in to mempool transactions, ensuring that standard historical queries are optimized for speed by avoiding unnecessary mempool lookups.
  • It replaces the confusing special range with a clear, explicit control mechanism.

Motivation and Context

Follow-up on @yyforyongyu's comment #1091 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions