mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-21 22:11:41 +01:00
lnwire: add bool types to codec for SCB format
This commit is contained in:
parent
64b8facf0e
commit
a508a62b8c
1 changed files with 18 additions and 0 deletions
|
@ -416,6 +416,14 @@ func WriteElement(w io.Writer, element interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
case bool:
|
||||
var b [1]byte
|
||||
if e {
|
||||
b[0] = 1
|
||||
}
|
||||
if _, err := w.Write(b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Unknown type in WriteElement: %T", e)
|
||||
}
|
||||
|
@ -440,6 +448,16 @@ func WriteElements(w io.Writer, elements ...interface{}) error {
|
|||
func ReadElement(r io.Reader, element interface{}) error {
|
||||
var err error
|
||||
switch e := element.(type) {
|
||||
case *bool:
|
||||
var b [1]byte
|
||||
if _, err := io.ReadFull(r, b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if b[0] == 1 {
|
||||
*e = true
|
||||
}
|
||||
|
||||
case *NodeAlias:
|
||||
var a [32]byte
|
||||
if _, err := io.ReadFull(r, a[:]); err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue