Repository navigation
node: Read block undo data on the scan thread - #103
Merged
Merged
Conversation
Reading the spent outputs in the block connected callback requires the chainstate manager, and the callback is registered before the manager exists, so it reached one through a OnceLock. The OnceLock was only needed because get_block_tree_entry returned None for every hash in bitcoinkernel 0.2.0. The lookup works in 0.3.0. Send the block and its hash to the scan thread and read the undo data there.
rustaceanrob
approved these changes
Sep 7, 2026
rustaceanrob
left a comment
Contributor
There was a problem hiding this comment.
LGTM, tested and ran this locally for a few blocks. Thanks for the cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On #50 the suggestion was to send the block over a channel and scan it on a consumer thread. I was under the impression that
get_block_tree_entryreturnedNonefor just-connected blocks because get_block_tree_entry returned None for every hash in bitcoinkernel 0.2.0., soread_spent_outputsstayed in the block connected callback, and the callback reached the chainstate manager through aOnceLockbecause it is registered before the manager exists.The lookup works in 0.3.0. and resolves the entry now. The callback sends the block and its hash, and the scan thread reads the undo data itself. The
OnceLockis gone and the disk read is off the kernel's validation thread.