Skip to content

index: improve TxoSpenderIndex readability and documentation - #34748

Closed
furszy wants to merge 2 commits into
bitcoin:masterfrom
furszy:2026_index_txospend_doc
Closed

furszy wants to merge 2 commits into
bitcoin:masterfrom
furszy:2026_index_txospend_doc

Conversation

@furszy

@furszy furszy commented Mar 5, 2026 •

Copy link
Copy Markdown
Member

This should help future ourselves and other devs to maintain the code. The code here
took me a bit to grasp, so I imagine others could be in the same situation.

First, TxoSpenderIndex::FindSpender returns an Expected<optional<TxoSpender>> but
the two levels of the return type were undocumented, making it unclear what a returned
nullopt means. So added doc clarifying each return case.

Second, the result-building loop in gettxspendingprevout was not super readable
to me, mainly due to the nested if/else chain and missing comments on what is going on
along the process.

Hope this helps others, if not, I can close it. It was helpful to me.

Hard to know what a returned std::Expected(std::nullopt) mean
if it is not documented anywhere.
@DrahtBot

DrahtBot commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Clarifies when the index will be used, renames confusing
`txospenderindex_ready` flag to `use_index`, and breaks up
the nested if/else chain into documented sections.
@fjahr

fjahr commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Did you see my suggested refactoring of the RPC? fjahr@a7b0e95

I just pulled this out of #34635 because it was controversial, see #34635 (comment). But I will reopen it as a standalone PR.

EDIT: Put it here: #34749

@furszy

furszy commented Mar 5, 2026 •

Copy link
Copy Markdown
Member Author

Did you see my suggested refactoring of the RPC? fjahr@a7b0e95
I just pulled this out of #34635 because it was controversial, see #34635 (comment).

Nope, I didn’t see it. Otherwise I would have ACKed the concept and left these changes there.
I did it in the context of #34747, took me a bit to grasp the current code during review.

Side topic, a new PR might not be needed, #34635 seems short as is now. Could add it there. . You already pushed it :p.

And dunno about the "controversial" argument. Will check your code, but this one at least is purely
adding documentation and breaking up the nested blocks. Nothing really serious.

@fjahr

fjahr commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Side topic, a new PR might not be needed, #34635 seems short as is now. Could add it there.

And dunno about the "controversial" argument.

Thanks, please read #34635 (comment) to see why I pulled it out :) My version does a bit more than your refactoring. Let's see how we can converge on one improvement that everyone can agree on.

@furszy

furszy commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

Thanks, please read #34635 (comment) to see why I pulled it out :) My version does a bit more than your refactoring. Let's see how we can converge on one improvement that everyone can agree on.

Yeah absolutely, will do.

@furszy

furszy commented Mar 6, 2026

Copy link
Copy Markdown
Member Author

Closing. Leaving it in @fjahr's hands. Let's continue on your PR.

@furszy furszy closed this Mar 6, 2026
sedited added a commit that referenced this pull request Mar 12, 2026
d236415 rpc: Refactor gettxspendingprevout to be easier to parse (Fabian Jahr)

Pull request description:

  This refactoring commit was originally part of #34635 but the the change was some-what controversial: #34635 (comment) and the discussion was blocking the rest of the uncontroversial changes from moving forward.

  It looks like #34748 is trying to achieve something similar now, we'll have to see how the different approached converge but at least there seems to be some more conceptual interest than appeared on #34635 originally.

ACKs for top commit:
  hodlinator:
    ACK d236415
  sedited:
    Re-ACK d236415
  furszy:
    utACK d236415

Tree-SHA512: 3df70bb8f143247f66d52430b3d8a4ecc5f0b80aa68ef3fc9082739b6f1be02fa9ef88ff134bb01034c9b6006400342e71fa8dc0a203d8e13b4bf6e21d1b05a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants