lnwire: add bool types to codec for SCB format
This commit is contained in:
parent
64b8facf0e
commit
a508a62b8c
@ -416,6 +416,14 @@ func WriteElement(w io.Writer, element interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case bool:
|
||||||
|
var b [1]byte
|
||||||
|
if e {
|
||||||
|
b[0] = 1
|
||||||
|
}
|
||||||
|
if _, err := w.Write(b[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unknown type in WriteElement: %T", e)
|
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 {
|
func ReadElement(r io.Reader, element interface{}) error {
|
||||||
var err error
|
var err error
|
||||||
switch e := element.(type) {
|
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:
|
case *NodeAlias:
|
||||||
var a [32]byte
|
var a [32]byte
|
||||||
if _, err := io.ReadFull(r, a[:]); err != nil {
|
if _, err := io.ReadFull(r, a[:]); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user