discovery/gossiper: include max HTLC when rebroadcasting stale channel updates
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
parent
19c403711e
commit
207c4f030a
@ -1321,6 +1321,17 @@ func (d *AuthenticatedGossiper) retransmitStaleChannels() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this edge has a ChannelUpdate that was created before the
|
||||||
|
// introduction of the MaxHTLC field, then we'll update this
|
||||||
|
// edge to propagate this information in the network.
|
||||||
|
if edge.MessageFlags&lnwire.ChanUpdateOptionMaxHtlc == 0 {
|
||||||
|
edgesToUpdate = append(edgesToUpdate, updateTuple{
|
||||||
|
info: info,
|
||||||
|
edge: edge,
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
const broadcastInterval = time.Hour * 24
|
const broadcastInterval = time.Hour * 24
|
||||||
|
|
||||||
timeElapsed := time.Since(edge.LastUpdate)
|
timeElapsed := time.Since(edge.LastUpdate)
|
||||||
@ -2507,7 +2518,12 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
|||||||
edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
|
edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
|
||||||
*lnwire.ChannelUpdate, error) {
|
*lnwire.ChannelUpdate, error) {
|
||||||
|
|
||||||
var err error
|
// We'll make sure we support the new max_htlc field if not already
|
||||||
|
// present.
|
||||||
|
if edge.MessageFlags&lnwire.ChanUpdateOptionMaxHtlc == 0 {
|
||||||
|
edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc
|
||||||
|
edge.MaxHTLC = lnwire.NewMSatFromSatoshis(info.Capacity)
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure timestamp is always increased, such that our update gets
|
// Make sure timestamp is always increased, such that our update gets
|
||||||
// propagated.
|
// propagated.
|
||||||
@ -2516,6 +2532,7 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
|||||||
timestamp = edge.LastUpdate.Unix() + 1
|
timestamp = edge.LastUpdate.Unix() + 1
|
||||||
}
|
}
|
||||||
edge.LastUpdate = time.Unix(timestamp, 0)
|
edge.LastUpdate = time.Unix(timestamp, 0)
|
||||||
|
|
||||||
chanUpdate := &lnwire.ChannelUpdate{
|
chanUpdate := &lnwire.ChannelUpdate{
|
||||||
ChainHash: info.ChainHash,
|
ChainHash: info.ChainHash,
|
||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(edge.ChannelID),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(edge.ChannelID),
|
||||||
@ -2524,10 +2541,13 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
|||||||
ChannelFlags: edge.ChannelFlags,
|
ChannelFlags: edge.ChannelFlags,
|
||||||
TimeLockDelta: edge.TimeLockDelta,
|
TimeLockDelta: edge.TimeLockDelta,
|
||||||
HtlcMinimumMsat: edge.MinHTLC,
|
HtlcMinimumMsat: edge.MinHTLC,
|
||||||
|
HtlcMaximumMsat: edge.MaxHTLC,
|
||||||
BaseFee: uint32(edge.FeeBaseMSat),
|
BaseFee: uint32(edge.FeeBaseMSat),
|
||||||
FeeRate: uint32(edge.FeeProportionalMillionths),
|
FeeRate: uint32(edge.FeeProportionalMillionths),
|
||||||
ExtraOpaqueData: edge.ExtraOpaqueData,
|
ExtraOpaqueData: edge.ExtraOpaqueData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
chanUpdate.Signature, err = lnwire.NewSigFromRawSignature(edge.SigBytes)
|
chanUpdate.Signature, err = lnwire.NewSigFromRawSignature(edge.SigBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user