graph/db: use route.Vertex for channel keys
Replace [33]byte with route.Vertex for NodeKey1Bytes, NodeKey2Bytes, BitcoinKey1Bytes, and BitcoinKey2Bytes in ChannelEdgeInfo. Since route.Vertex is defined as [33]byte, this change is functionally equivalent but provides better type safety and consistency with the rest of the routing subsystem. OtherNodeKeyBytes is also updated to return route.Vertex.
This commit is contained in:
2 files changed
+12
-11
No files matched your search
@@ -1262,9 +1262,9 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
||||
|
||||
// Mark edge policies for both sides as unknown. This is to enable
|
||||
// efficient incoming channel lookup for a node.
|
||||
keys := []*[33]byte{
|
||||
&edge.NodeKey1Bytes,
|
||||
&edge.NodeKey2Bytes,
|
||||
keys := []route.Vertex{
|
||||
edge.NodeKey1Bytes,
|
||||
edge.NodeKey2Bytes,
|
||||
}
|
||||
for _, key := range keys {
|
||||
err := putChanEdgePolicyUnknown(edges, edge.ChannelID, key[:])
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
|
||||
// ChannelEdgeInfo represents a fully authenticated channel along with all its
|
||||
@@ -29,16 +30,16 @@ type ChannelEdgeInfo struct {
|
||||
ChainHash chainhash.Hash
|
||||
|
||||
// NodeKey1Bytes is the raw public key of the first node.
|
||||
NodeKey1Bytes [33]byte
|
||||
NodeKey1Bytes route.Vertex
|
||||
|
||||
// NodeKey2Bytes is the raw public key of the first node.
|
||||
NodeKey2Bytes [33]byte
|
||||
// NodeKey2Bytes is the raw public key of the second node.
|
||||
NodeKey2Bytes route.Vertex
|
||||
|
||||
// BitcoinKey1Bytes is the raw public key of the first node.
|
||||
BitcoinKey1Bytes [33]byte
|
||||
BitcoinKey1Bytes route.Vertex
|
||||
|
||||
// BitcoinKey2Bytes is the raw public key of the first node.
|
||||
BitcoinKey2Bytes [33]byte
|
||||
// BitcoinKey2Bytes is the raw public key of the second node.
|
||||
BitcoinKey2Bytes route.Vertex
|
||||
|
||||
// Features is the list of protocol features supported by this channel
|
||||
// edge.
|
||||
@@ -90,7 +91,7 @@ func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error) {
|
||||
|
||||
// OtherNodeKeyBytes returns the node key bytes of the other end of the channel.
|
||||
func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
|
||||
[33]byte, error) {
|
||||
route.Vertex, error) {
|
||||
|
||||
switch {
|
||||
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
|
||||
@@ -98,7 +99,7 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
|
||||
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
|
||||
return c.NodeKey1Bytes, nil
|
||||
default:
|
||||
return [33]byte{}, fmt.Errorf("node not participating in " +
|
||||
return route.Vertex{}, fmt.Errorf("node not participating in " +
|
||||
"this channel")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user