From 4b2eb9cb81f37bdc1980701183abfe6f1e972620 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 20 Sep 2019 11:26:45 +0200 Subject: [PATCH] discovery: push max htlc migration further up the call tree As a preparation for making the gossiper less responsible for validating and supplementing local channel policy updates, this commits moves the on-the-fly max htlc migration up the call tree. The plan for a follow up commit is to move it out of the gossiper completely for local channel updates, so that we don't need to return a list of final applied policies anymore. --- discovery/gossiper.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index b5bbfe8d0..5a42f155a 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1211,6 +1211,11 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { // introduction of the MaxHTLC field, then we'll update this // edge to propagate this information in the network. if !edge.MessageFlags.HasMaxHtlc() { + // We'll make sure we support the new max_htlc field if + // not already present. + edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc + edge.MaxHTLC = lnwire.NewMSatFromSatoshis(info.Capacity) + edgesToUpdate = append(edgesToUpdate, updateTuple{ info: info, edge: edge, @@ -1369,6 +1374,10 @@ func (d *AuthenticatedGossiper) processChanPolicyUpdate( ) edge.TimeLockDelta = uint16(policyUpdate.newSchema.TimeLockDelta) + // Max htlc is currently always set to the channel capacity. + edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc + edge.MaxHTLC = lnwire.NewMSatFromSatoshis(info.Capacity) + edgesToUpdate = append(edgesToUpdate, edgeWithInfo{ info: info, edge: edge, @@ -2514,13 +2523,6 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo, edge *channeldb.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement, *lnwire.ChannelUpdate, error) { - // We'll make sure we support the new max_htlc field if not already - // present. - if !edge.MessageFlags.HasMaxHtlc() { - edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc - edge.MaxHTLC = lnwire.NewMSatFromSatoshis(info.Capacity) - } - // Make sure timestamp is always increased, such that our update gets // propagated. timestamp := time.Now().Unix()