lnwire/channel_update: add String method for ChanUpdate[Chan|Msg]Flags

In this commit, we fix the problem where it's annoying to parse a
bitfield printed out in decimal by writing a String method for the
ChanUpdate[Chan|Msg]Flags bitfield.

Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
Valentine Wallace
2019-01-12 18:59:43 +01:00
committed by Johan T. Halseth
parent 0fd6004958
commit f0ba4b454c
2 changed files with 55 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package lnwire
import (
"bytes"
"fmt"
"io"
"io/ioutil"
@@ -12,6 +13,11 @@ import (
// present in the ChannelUpdate.
type ChanUpdateMsgFlags uint8
// String returns the bitfield flags as a string.
func (c ChanUpdateMsgFlags) String() string {
return fmt.Sprintf("%08b", c)
}
// ChanUpdateChanFlags is a bitfield that signals various options concerning a
// particular channel edge. Each bit is to be examined in order to determine
// how the ChannelUpdate message is to be interpreted.
@@ -29,6 +35,11 @@ const (
ChanUpdateDisabled
)
// String returns the bitfield flags as a string.
func (c ChanUpdateChanFlags) String() string {
return fmt.Sprintf("%08b", c)
}
// ChannelUpdate message is used after channel has been initially announced.
// Each side independently announces its fees and minimum expiry for HTLCs and
// other parameters. Also this message is used to redeclare initially set