routing: add color to node update

This commit is contained in:
Xavi Soler
2018-12-21 17:32:43 +01:00
parent ee2e49141e
commit 28021361d1
2 changed files with 41 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package routing
import (
"fmt"
"image/color"
"net"
"sync"
"sync/atomic"
@ -246,6 +247,9 @@ type NetworkNodeUpdate struct {
// Alias is the alias or nick name of the node.
Alias string
// Color is the node's color in hex code format.
Color string
}
// ChannelEdgeUpdate is an update for a new channel within the ChannelGraph.
@ -321,6 +325,7 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
Addresses: m.Addresses,
IdentityKey: pubKey,
Alias: m.Alias,
Color: EncodeHexColor(m.Color),
}
nodeUpdate.IdentityKey.Curve = nil
@ -388,3 +393,8 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
"unknown message type %T", msg)
}
}
// EncodeHexColor takes a color and returns it in hex code format.
func EncodeHexColor(color color.RGBA) string {
return fmt.Sprintf("#%02x%02x%02x", color.R, color.G, color.B)
}