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:
Valentine WallaceandJohan T. Halseth authored and Johan T. Halseth committed 2019-01-22 08:42:26 +01:00
1 parent 375be936ce
commit 0fd6004958
21 files changed
+176 -113

No files matched your search

+6 -5
View File
@@ -2978,10 +2978,10 @@ func (s *server) announceChanStatus(op wire.OutPoint, disabled bool) error {
if disabled {
// Set the bit responsible for marking a channel as disabled.
chanUpdate.Flags |= lnwire.ChanUpdateDisabled
chanUpdate.ChannelFlags |= lnwire.ChanUpdateDisabled
} else {
// Clear the bit responsible for marking a channel as disabled.
chanUpdate.Flags &= ^lnwire.ChanUpdateDisabled
chanUpdate.ChannelFlags &= ^lnwire.ChanUpdateDisabled
}
// We must now update the message's timestamp and generate a new
@@ -3066,9 +3066,9 @@ func extractChannelUpdate(ownerPubKey []byte,
owner := func(edge *channeldb.ChannelEdgePolicy) []byte {
var pubKey *btcec.PublicKey
switch {
case edge.Flags&lnwire.ChanUpdateDirection == 0:
case edge.ChannelFlags&lnwire.ChanUpdateDirection == 0:
pubKey, _ = info.NodeKey1()
case edge.Flags&lnwire.ChanUpdateDirection == 1:
case edge.ChannelFlags&lnwire.ChanUpdateDirection == 1:
pubKey, _ = info.NodeKey2()
}
@@ -3100,7 +3100,8 @@ func createChannelUpdate(info *channeldb.ChannelEdgeInfo,
ChainHash: info.ChainHash,
ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID),
Timestamp: uint32(policy.LastUpdate.Unix()),
Flags: policy.Flags,
MessageFlags: policy.MessageFlags,
ChannelFlags: policy.ChannelFlags,
TimeLockDelta: policy.TimeLockDelta,
HtlcMinimumMsat: policy.MinHTLC,
BaseFee: uint32(policy.FeeBaseMSat),