multi: add ChanEdgePolicyFromWire constructor for ChannelEdgePolicy

Add ChanEdgePolicyFromWire to construct ChannelEdgePolicy from channel
update messages, centralizing v1/v2 field mapping.
Update call sites to use the helper:

- discovery/gossiper: handleChanUpdate
- graph/builder: ApplyChannelUpdate
- routing/router_test: ApplyChannelUpdate test helper

This consolidates update-to-policy conversion logic across versions.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:24 +02:00
1 parent 9c7a12c0e0
commit a73c45946b
4 files changed
+69 -42

No files matched your search

+7 -14
View File
@@ -2968,20 +2968,13 @@ func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
return false
}
err := m.updateEdge(&models.ChannelEdgePolicy{
Version: msg.GossipVersion(),
SigBytes: msg.Signature.ToSignatureBytes(),
ChannelID: msg.ShortChannelID.ToUint64(),
LastUpdate: time.Unix(int64(msg.Timestamp), 0),
MessageFlags: msg.MessageFlags,
ChannelFlags: msg.ChannelFlags,
TimeLockDelta: msg.TimeLockDelta,
MinHTLC: msg.HtlcMinimumMsat,
MaxHTLC: msg.HtlcMaximumMsat,
FeeBaseMSat: lnwire.MilliSatoshi(msg.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(msg.FeeRate),
ExtraOpaqueData: msg.ExtraOpaqueData,
})
update, err := models.ChanEdgePolicyFromWire(
msg.ShortChannelID.ToUint64(), msg,
)
if err != nil {
return false
}
err = m.updateEdge(update)
return err == nil
}