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.
This commit is contained in:
5 files changed
+59
-45
No files matched your search
@@ -30,7 +30,7 @@ func TestNodeEdgeUnifier(t *testing.T) {
|
||||
FeeProportionalMillionths: 100000,
|
||||
FeeBaseMSat: 30,
|
||||
TimeLockDelta: 60,
|
||||
MessageFlags: lnwire.ChanUpdateRequiredMaxHtlc,
|
||||
HasMaxHTLC: true,
|
||||
MaxHTLC: 5000,
|
||||
MinHTLC: 100,
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func TestNodeEdgeUnifier(t *testing.T) {
|
||||
FeeProportionalMillionths: 190000,
|
||||
FeeBaseMSat: 10,
|
||||
TimeLockDelta: 40,
|
||||
MessageFlags: lnwire.ChanUpdateRequiredMaxHtlc,
|
||||
HasMaxHTLC: true,
|
||||
MaxHTLC: 4000,
|
||||
MinHTLC: 100,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user