lnwire: add new ChanUpdateFlag for the ChannelUpdate flag bitmask

In this commit, we add a new type to the lnwire package:
ChanUpdateFlag. This type represent the bitfield that’s used within the
ChannelUpdate message to give additional details as how the message
should be interpreted.
This commit is contained in:
Olaoluwa Osuntokun
2017-11-30 22:21:27 -08:00
parent c3ec32e67b
commit 5e3dbfcd78
3 changed files with 36 additions and 4 deletions

View File

@@ -98,6 +98,12 @@ func writeElement(w io.Writer, element interface{}) error {
if _, err := w.Write(b[:]); err != nil {
return err
}
case ChanUpdateFlag:
var b [2]byte
binary.BigEndian.PutUint16(b[:], uint16(e))
if _, err := w.Write(b[:]); err != nil {
return err
}
case ErrorCode:
var b [2]byte
binary.BigEndian.PutUint16(b[:], uint16(e))
@@ -406,6 +412,12 @@ func readElement(r io.Reader, element interface{}) error {
return err
}
*e = binary.BigEndian.Uint16(b[:])
case *ChanUpdateFlag:
var b [2]byte
if _, err := io.ReadFull(r, b[:]); err != nil {
return err
}
*e = ChanUpdateFlag(binary.BigEndian.Uint16(b[:]))
case *ErrorCode:
var b [2]byte
if _, err := io.ReadFull(r, b[:]); err != nil {