mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
channeldb: convert FetchOtherNode to ChannelGraph method
To prepare for the `kvdb.Backend` member of `ChannelEdgeInfo` being removed, the `FetchOtherNode` method is moved from the `ChannelEdgeInfo` to the `ChannelGraph` struct.
This commit is contained in:
parent
6d878c65fc
commit
9dc1a1dfec
2 changed files with 8 additions and 6 deletions
|
@ -3206,16 +3206,16 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (
|
||||||
// the target node in the channel. This is useful when one knows the pubkey of
|
// the target node in the channel. This is useful when one knows the pubkey of
|
||||||
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
||||||
// end of the channel.
|
// end of the channel.
|
||||||
func (c *ChannelEdgeInfo) FetchOtherNode(tx kvdb.RTx,
|
func (c *ChannelGraph) FetchOtherNode(tx kvdb.RTx, channel *ChannelEdgeInfo,
|
||||||
thisNodeKey []byte) (*LightningNode, error) {
|
thisNodeKey []byte) (*LightningNode, error) {
|
||||||
|
|
||||||
// Ensure that the node passed in is actually a member of the channel.
|
// Ensure that the node passed in is actually a member of the channel.
|
||||||
var targetNodeBytes [33]byte
|
var targetNodeBytes [33]byte
|
||||||
switch {
|
switch {
|
||||||
case bytes.Equal(c.NodeKey1Bytes[:], thisNodeKey):
|
case bytes.Equal(channel.NodeKey1Bytes[:], thisNodeKey):
|
||||||
targetNodeBytes = c.NodeKey2Bytes
|
targetNodeBytes = channel.NodeKey2Bytes
|
||||||
case bytes.Equal(c.NodeKey2Bytes[:], thisNodeKey):
|
case bytes.Equal(channel.NodeKey2Bytes[:], thisNodeKey):
|
||||||
targetNodeBytes = c.NodeKey1Bytes
|
targetNodeBytes = channel.NodeKey1Bytes
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("node not participating in this channel")
|
return nil, fmt.Errorf("node not participating in this channel")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3107,7 +3107,9 @@ func (s *server) establishPersistentConnections() error {
|
||||||
|
|
||||||
// We'll now fetch the peer opposite from us within this
|
// We'll now fetch the peer opposite from us within this
|
||||||
// channel so we can queue up a direct connection to them.
|
// channel so we can queue up a direct connection to them.
|
||||||
channelPeer, err := chanInfo.FetchOtherNode(tx, selfPub)
|
channelPeer, err := s.graphDB.FetchOtherNode(
|
||||||
|
tx, chanInfo, selfPub,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to fetch channel peer for "+
|
return fmt.Errorf("unable to fetch channel peer for "+
|
||||||
"ChannelPoint(%v): %v", chanInfo.ChannelPoint,
|
"ChannelPoint(%v): %v", chanInfo.ChannelPoint,
|
||||||
|
|
Loading…
Add table
Reference in a new issue