lnwire: use color.RGBA instead of custom type in NodeAnnouncment
This commit is contained in:
parent
724adb158c
commit
4b6ada98d6
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
"math"
|
||||
|
||||
@ -355,8 +356,8 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case RGB:
|
||||
if err := writeElements(w, e.red, e.green, e.blue); err != nil {
|
||||
case color.RGBA:
|
||||
if err := writeElements(w, e.R, e.G, e.B); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -689,11 +690,11 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
}
|
||||
|
||||
*e = addresses
|
||||
case *RGB:
|
||||
case *color.RGBA:
|
||||
err := readElements(r,
|
||||
&e.red,
|
||||
&e.green,
|
||||
&e.blue,
|
||||
&e.R,
|
||||
&e.G,
|
||||
&e.B,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -3,6 +3,7 @@ package lnwire
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"image/color"
|
||||
"math"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
@ -404,10 +405,10 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
Features: randRawFeatureVector(r),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
Alias: a,
|
||||
RGBColor: RGB{
|
||||
red: uint8(r.Int31()),
|
||||
green: uint8(r.Int31()),
|
||||
blue: uint8(r.Int31()),
|
||||
RGBColor: color.RGBA{
|
||||
R: uint8(r.Int31()),
|
||||
G: uint8(r.Int31()),
|
||||
B: uint8(r.Int31()),
|
||||
},
|
||||
// TODO(roasbeef): proper gen rand addrs
|
||||
Addresses: testAddrs,
|
||||
|
@ -3,6 +3,7 @@ package lnwire
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
"net"
|
||||
"unicode/utf8"
|
||||
@ -15,14 +16,6 @@ var (
|
||||
endPort uint16 = 49151
|
||||
)
|
||||
|
||||
// RGB is used to represent the "color" of a particular node encoded as a 24
|
||||
// bit value.
|
||||
type RGB struct {
|
||||
red uint8
|
||||
green uint8
|
||||
blue uint8
|
||||
}
|
||||
|
||||
// NodeAlias a hex encoded UTF-8 string that may be displayed as an alternative
|
||||
// to the node's ID. Notice that aliases are not unique and may be freely
|
||||
// chosen by the node operators.
|
||||
@ -69,7 +62,7 @@ type NodeAnnouncement struct {
|
||||
|
||||
// RGBColor is used to customize their node's appearance in maps and
|
||||
// graphs
|
||||
RGBColor RGB
|
||||
RGBColor color.RGBA
|
||||
|
||||
// Alias is used to customize their node's appearance in maps and
|
||||
// graphs
|
||||
|
Loading…
Reference in New Issue
Block a user