AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 14 Bitcoin

graph/db: refactor CachedEdgePolicy to use explicit boolean fields

Public commit record

What the developer wrote

Authored by Elle Mouton

83/100 · Strong
graph/db: refactor CachedEdgePolicy to use explicit boolean fields

Replace MessageFlags and ChannelFlags bitfields in CachedEdgePolicy
with explicit boolean fields to improve clarity and support both v1
and v2 channel updates:

- Replace MessageFlags with HasMaxHTLC boolean.
- Replace ChannelFlags with IsNode1 and IsDisabled booleans.
- Update NewCachedPolicy to extract these fields version-appropriately:
- For v1: derive from MessageFlags and ChannelFlags bits.
- For v2: derive from policy.SecondPeer and policy.DisableFlags.

Update all call sites that used method calls IsNode1() and IsDisabled()
to instead access the fields directly. This includes:
- graph_cache.go: policy direction and disable checks
- unified_edges.go: HasMaxHTLC and IsDisabled checks
- Tests: policy construction and assertions

This refactoring improves readability by making the cached policy's
state explicit rather than encoded in bitfields, and enables seamless
support for both gossip protocol versions.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit is a straightforward internal code cleanup in LND's routing graph cache. It replaces compact bit-field flags with clearly named true/false fields (e.g., 'IsDisabled', 'IsNode1', 'HasMaxHTLC') and updates the code that reads them. There is no security fix or externally reported vulnerability here; it is a readability and maintainability refactor that also prepares the code for a newer gossip protocol version.

Recommended action

No security action required. Review as normal code-quality refactor; verify test coverage remains equivalent for v1 and v2 gossip policy conversion.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 14/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.