multi: partition lnwire.ChanUpdateFlag into ChannelFlags and MessageFlags
In this commit: * we partition lnwire.ChanUpdateFlag into two (ChanUpdateChanFlags and ChanUpdateMsgFlags), from a uint16 to a pair of uint8's * we rename the ChannelUpdate.Flags to ChannelFlags and add an additional MessageFlags field, which will be used to indicate the presence of the optional field HtlcMaximumMsat within the ChannelUpdate. * we partition ChannelEdgePolicy.Flags into message and channel flags. This change corresponds to the partitioning of the ChannelUpdate's Flags field into MessageFlags and ChannelFlags. Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
1 parent
375be936ce
commit
0fd6004958
21 files changed
+176
-113
No files matched your search
+14
-12
@@ -560,7 +560,7 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
||||
}
|
||||
|
||||
// channelUpdateID is a unique identifier for ChannelUpdate messages, as
|
||||
// channel updates can be identified by the (ShortChannelID, Flags)
|
||||
// channel updates can be identified by the (ShortChannelID, ChannelFlags)
|
||||
// tuple.
|
||||
type channelUpdateID struct {
|
||||
// channelID represents the set of data which is needed to
|
||||
@@ -570,7 +570,7 @@ type channelUpdateID struct {
|
||||
// Flags least-significant bit must be set to 0 if the creating node
|
||||
// corresponds to the first node in the previously sent channel
|
||||
// announcement and 1 otherwise.
|
||||
flags lnwire.ChanUpdateFlag
|
||||
flags lnwire.ChanUpdateChanFlags
|
||||
}
|
||||
|
||||
// msgWithSenders is a wrapper struct around a message, and the set of peers
|
||||
@@ -669,13 +669,13 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
|
||||
mws.senders[sender] = struct{}{}
|
||||
d.channelAnnouncements[deDupKey] = mws
|
||||
|
||||
// Channel updates are identified by the (short channel id, flags)
|
||||
// tuple.
|
||||
// Channel updates are identified by the (short channel id,
|
||||
// channelflags) tuple.
|
||||
case *lnwire.ChannelUpdate:
|
||||
sender := routing.NewVertex(message.source)
|
||||
deDupKey := channelUpdateID{
|
||||
msg.ShortChannelID,
|
||||
msg.Flags,
|
||||
msg.ChannelFlags,
|
||||
}
|
||||
|
||||
oldTimestamp := uint32(0)
|
||||
@@ -1911,7 +1911,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
||||
// announcement for this edge.
|
||||
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
||||
if d.cfg.Router.IsStaleEdgePolicy(
|
||||
msg.ShortChannelID, timestamp, msg.Flags,
|
||||
msg.ShortChannelID, timestamp, msg.ChannelFlags,
|
||||
) {
|
||||
|
||||
nMsg.err <- nil
|
||||
@@ -1986,9 +1986,9 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
||||
// edge is being updated.
|
||||
var pubKey *btcec.PublicKey
|
||||
switch {
|
||||
case msg.Flags&lnwire.ChanUpdateDirection == 0:
|
||||
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 0:
|
||||
pubKey, _ = chanInfo.NodeKey1()
|
||||
case msg.Flags&lnwire.ChanUpdateDirection == 1:
|
||||
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 1:
|
||||
pubKey, _ = chanInfo.NodeKey2()
|
||||
}
|
||||
|
||||
@@ -2009,7 +2009,8 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
||||
SigBytes: msg.Signature.ToSignatureBytes(),
|
||||
ChannelID: shortChanID,
|
||||
LastUpdate: timestamp,
|
||||
Flags: msg.Flags,
|
||||
MessageFlags: msg.MessageFlags,
|
||||
ChannelFlags: msg.ChannelFlags,
|
||||
TimeLockDelta: msg.TimeLockDelta,
|
||||
MinHTLC: msg.HtlcMinimumMsat,
|
||||
FeeBaseMSat: lnwire.MilliSatoshi(msg.BaseFee),
|
||||
@@ -2041,9 +2042,9 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
||||
// Get our peer's public key.
|
||||
var remotePub *btcec.PublicKey
|
||||
switch {
|
||||
case msg.Flags&lnwire.ChanUpdateDirection == 0:
|
||||
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 0:
|
||||
remotePub, _ = chanInfo.NodeKey2()
|
||||
case msg.Flags&lnwire.ChanUpdateDirection == 1:
|
||||
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 1:
|
||||
remotePub, _ = chanInfo.NodeKey1()
|
||||
}
|
||||
|
||||
@@ -2517,7 +2518,8 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
||||
ChainHash: info.ChainHash,
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(edge.ChannelID),
|
||||
Timestamp: uint32(timestamp),
|
||||
Flags: edge.Flags,
|
||||
MessageFlags: edge.MessageFlags,
|
||||
ChannelFlags: edge.ChannelFlags,
|
||||
TimeLockDelta: edge.TimeLockDelta,
|
||||
HtlcMinimumMsat: edge.MinHTLC,
|
||||
BaseFee: uint32(edge.FeeBaseMSat),
|
||||
|
||||
Reference in new issue
Block a user