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:
4 files changed
+69
-42
No files matched your search
+7
-14
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user