From 14832d8c09539ad5b40413c7336fa1e08203b2cb Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 14 Jul 2017 17:10:29 -0700 Subject: [PATCH] lnwallet+lnwire: minor grammatical fixes after UpdateFee merge --- lnwallet/channel.go | 38 ++++++++++++++++++++------------------ lnwire/update_fee.go | 8 ++++---- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 6b5d6a94d..51bde351d 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -638,12 +638,13 @@ type LightningChannel struct { // pendingFeeUpdate is set to the fee-per-kw we last sent (if we are // channel initiator) or received (if non-initiator) in an update fee - // message, which haven't yet been included in a commitment. - // It will be nil if no fee update is un-committed. + // message, which haven't yet been included in a commitment. It will + // be nil if no fee update is un-committed. pendingFeeUpdate *btcutil.Amount // pendingAckFeeUpdate is set to the last committed fee update which is - // not yet ACKed. Set to nil if no such update. + // not yet ACKed. This value will be nil if a fee update hasn't been + // initiated. pendingAckFeeUpdate *btcutil.Amount // rHashMap is a map with PaymentHashes pointing to their respective @@ -1349,31 +1350,32 @@ func (lc *LightningChannel) fetchCommitmentView(remoteChain bool, // Initiate feePerKw to the last committed fee for this chain. feePerKw := commitChain.tail().feePerKw - // Check if any fee updates have taken place since that last commitment. + // Check if any fee updates have taken place since that last + // commitment. if lc.channelState.IsInitiator { - - // The case where we sent an update_fee message since our last - // commitment, and now we are signing that one. - if remoteChain && lc.pendingFeeUpdate != nil { + switch { + // We've sent an update_fee message since our last commitment, + // and now are now creating a commitment that reflects the new + // fee update. + case remoteChain && lc.pendingFeeUpdate != nil: feePerKw = *lc.pendingFeeUpdate - } - // The case where we committed to a sent fee update, and now we - // got a commitment that ACKed that update. - if !remoteChain && lc.pendingAckFeeUpdate != nil { + // We've created a new commitment for the remote chain that + // includes a fee update, and have not received a commitment + // after the fee update has been ACked. + case !remoteChain && lc.pendingAckFeeUpdate != nil: feePerKw = *lc.pendingAckFeeUpdate } } else { - - // We received a fee update since last received commitment, so - // this received commitment will sign that update. - if !remoteChain && lc.pendingFeeUpdate != nil { + switch { + // We've received a fee update since the last local commitment, + // so we'll include the fee update in the current view. + case !remoteChain && lc.pendingFeeUpdate != nil: feePerKw = *lc.pendingFeeUpdate - } // Earlier we received a commitment that signed an earlier fee // update, and now we must ACK that update. - if remoteChain && lc.pendingAckFeeUpdate != nil { + case remoteChain && lc.pendingAckFeeUpdate != nil: feePerKw = *lc.pendingAckFeeUpdate } } diff --git a/lnwire/update_fee.go b/lnwire/update_fee.go index cbf21b614..626a3fa14 100644 --- a/lnwire/update_fee.go +++ b/lnwire/update_fee.go @@ -29,8 +29,8 @@ func NewUpdateFee(chanID ChannelID, feePerKw btcutil.Amount) *UpdateFee { // interface. var _ Message = (*UpdateFee)(nil) -// Decode deserializes a serialized UpdateFee message stored in the -// passed io.Reader observing the specified protocol version. +// Decode deserializes a serialized UpdateFee message stored in the passed +// io.Reader observing the specified protocol version. // // This is part of the lnwire.Message interface. func (c *UpdateFee) Decode(r io.Reader, pver uint32) error { @@ -59,8 +59,8 @@ func (c *UpdateFee) MsgType() MessageType { return MsgUpdateFee } -// MaxPayloadLength returns the maximum allowed payload size for a -// UpdateFee complete message observing the specified protocol version. +// MaxPayloadLength returns the maximum allowed payload size for a UpdateFee +// complete message observing the specified protocol version. // // This is part of the lnwire.Message interface. func (c *UpdateFee) MaxPayloadLength(uint32) uint32 {