mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 19:10:59 +02:00
routing: add color to node update
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user