blockchain: add statusHeaderStored for blockNode status
What changed, and why it matters
This commit simply adds a new bookkeeping flag and a helper method to track whether a block header has been stored on disk. It does not change any security-sensitive behavior, fix a bug, or alter how data is validated. There is no indication this is a security patch.
No security action required. Review as normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces a new blockNode status bit statusHeaderStored and a HaveHeader() accessor in blockchain/blockindex.go. It is a preparatory/refactoring change to support block index entries that may have only the header persisted without full block data. No validation logic, storage routines, or network handling are modified.
Changed components
blockchain/blockindex.goInspect captured patch +8 / −0
diff --git a/blockchain/blockindex.go b/blockchain/blockindex.go
index 5273cb4..3e1606f 100644
--- a/blockchain/blockindex.go
+++ b/blockchain/blockindex.go
@@ -33,6 +33,9 @@ const (
// has failed validation, thus the block is also invalid.
statusInvalidAncestor
+ // statusHeaderStored indicates that the block's header is stored on disk.
+ statusHeaderStored
+
// statusNone indicates that the block has no validation state flags set.
//
// NOTE: This must be defined last in order to avoid influencing iota.
@@ -46,6 +49,11 @@ func (status blockStatus) HaveData() bool {
return status&statusDataStored != 0
}
+// HaveHeader returns whether the header data is stored in the database.
+func (status blockStatus) HaveHeader() bool {
+ return status&statusHeaderStored != 0
+}
+
// KnownValid returns whether the block is known to be valid. This will return
// false for a valid block that has not been fully validated yet.
func (status blockStatus) KnownValid() bool {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.