mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-19 20:25:51 +01:00
lnwire: update NodeAnnouncement to handle multiple addresses
This commit modifies address handling in the NodeAnnouncement struct, switching from net.TCPAddr to []net.Addr. This enables more flexible address handling with multiple types and multiple addresses for each node. This commit addresses the first part of issue #131 .
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
65c15c4cb0
commit
9ffac9eae1
21
rpcserver.go
21
rpcserver.go
@@ -1381,12 +1381,21 @@ func (r *rpcServer) DescribeGraph(context.Context,
|
||||
// within the graph), collating their current state into the RPC
|
||||
// response.
|
||||
err := graph.ForEachNode(func(node *channeldb.LightningNode) error {
|
||||
nodeAddrs := make([]*lnrpc.NodeAddress, 0)
|
||||
for _, addr := range node.Addresses {
|
||||
nodeAddr := &lnrpc.NodeAddress{
|
||||
Network: addr.Network(),
|
||||
Addr: addr.String(),
|
||||
}
|
||||
nodeAddrs = append(nodeAddrs, nodeAddr)
|
||||
}
|
||||
resp.Nodes = append(resp.Nodes, &lnrpc.LightningNode{
|
||||
LastUpdate: uint32(node.LastUpdate.Unix()),
|
||||
PubKey: hex.EncodeToString(node.PubKey.SerializeCompressed()),
|
||||
Address: node.Address.String(),
|
||||
Addresses: nodeAddrs,
|
||||
Alias: node.Alias,
|
||||
})
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1516,12 +1525,20 @@ func (r *rpcServer) GetNodeInfo(_ context.Context, in *lnrpc.NodeInfoRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeAddrs := make([]*lnrpc.NodeAddress, 0)
|
||||
for _, addr := range node.Addresses {
|
||||
nodeAddr := &lnrpc.NodeAddress{
|
||||
Network: addr.Network(),
|
||||
Addr: addr.String(),
|
||||
}
|
||||
nodeAddrs = append(nodeAddrs, nodeAddr)
|
||||
}
|
||||
// TODO(roasbeef): list channels as well?
|
||||
return &lnrpc.NodeInfo{
|
||||
Node: &lnrpc.LightningNode{
|
||||
LastUpdate: uint32(node.LastUpdate.Unix()),
|
||||
PubKey: in.PubKey,
|
||||
Address: node.Address.String(),
|
||||
Addresses: nodeAddrs,
|
||||
Alias: node.Alias,
|
||||
},
|
||||
NumChannels: numChannels,
|
||||
|
||||
Reference in New Issue
Block a user