← 输入框|github.com|刷新
Skip to content

node: Read block undo data on the scan thread - #103

Merged
rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:scan-thread-undo
Sep 7, 2026
Merged

rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:scan-thread-undo

Conversation

@pzafonte

@pzafonte pzafonte commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

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_entry returned None for just-connected blocks because get_block_tree_entry returned None for every hash in bitcoinkernel 0.2.0., so read_spent_outputs stayed in the block connected callback, and the callback reached the chainstate manager through a OnceLock because 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 OnceLock is gone and the disk read is off the kernel's validation thread.

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 rustaceanrob 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.

LGTM, tested and ran this locally for a few blocks. Thanks for the cleanup

@rustaceanrob
rustaceanrob merged commit 34b93b4 into kernel-node:master Sep 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants