Skip to content

validation: Separate check-only version of ConnectBlock - #21

Closed
optout21 wants to merge 1 commit into
masterfrom
connectblock-checkonly
Closed

optout21 wants to merge 1 commit into
masterfrom
connectblock-checkonly

Conversation

@optout21

Copy link
Copy Markdown
Owner

This is a small code-hygiene change to ConnectBlock method.

Problem: In the "check-only" mode of ConnectBlock the mutability of the CBlockIndex parameter is inconsistent with the semantics. In the default operation, ConnectBlock changes the provided CBlockIndex. However, it has a special "check-only" mode, where the provided chain is not changed. This mode is used from only one call site (TestBlockValidity), and is signaled by the fJustCheck = true flag.

Solution: Provide two versions of ConnectBlock: one with mutable chain and one "check-only" with const chain. There is no need for the fJustCheck flag. Both reuse the same internal implementation.

Additional info:

@optout21 optout21 mentioned this pull request Aug 24, 2026
@optout21
optout21 force-pushed the connectblock-checkonly branch 2 times, most recently from f473d26 to 0e832db Compare August 24, 2026 07:00
@optout21
optout21 force-pushed the connectblock-checkonly branch 3 times, most recently from ddc6be9 to fe970b7 Compare September 11, 2026 08:22
New `TestConnectBlock` method for the check-only variant of `ConnectBlock`,
with const `CBlockIndex` parameter. The `fJustCheck` flag is no longer
present in the public method versions. It is still present in the
non-pubic common implementation method, but with reduced usage.
@optout21
optout21 force-pushed the connectblock-checkonly branch from fe970b7 to f478dc0 Compare September 26, 2026 04:50
@optout21

optout21 commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

--> bitcoin#36066

@optout21 optout21 closed this Nov 2, 2026
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.

1 participant