Skip to content

Commit d2186cc

Browse files
committed
Merge branch 'v0.5.2-beta-rc7-2583-p' into v0.5.2-beta-rc7
2 parents 6696ccc + d5fab39 commit d2186cc

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

server.go

+27-7
Original file line numberDiff line numberDiff line change
@@ -1651,19 +1651,39 @@ func (s *server) establishPersistentConnections() error {
16511651
if err != nil {
16521652
return err
16531653
}
1654+
16541655
// TODO(roasbeef): instead iterate over link nodes and query graph for
16551656
// each of the nodes.
1657+
selfPub := s.identityPriv.PubKey().SerializeCompressed()
16561658
err = sourceNode.ForEachChannel(nil, func(
1657-
_ *bbolt.Tx,
1658-
_ *channeldb.ChannelEdgeInfo,
1659+
tx *bbolt.Tx,
1660+
chanInfo *channeldb.ChannelEdgeInfo,
16591661
policy, _ *channeldb.ChannelEdgePolicy) error {
16601662

1661-
pubStr := string(policy.Node.PubKeyBytes[:])
1663+
// If the remote party has announced the channel to us, but we
1664+
// haven't yet, then we won't have a policy. However, we don't
1665+
// need this to connect to the peer, so we'll log it and move on.
1666+
if policy == nil {
1667+
srvrLog.Warnf("No channel policy found for "+
1668+
"ChannelPoint(%v): ", chanInfo.ChannelPoint)
1669+
}
1670+
1671+
// We'll now fetch the peer opposite from us within this
1672+
// channel so we can queue up a direct connection to them.
1673+
channelPeer, err := chanInfo.FetchOtherNode(tx, selfPub)
1674+
if err != nil {
1675+
return fmt.Errorf("unable to fetch channel peer for "+
1676+
"ChannelPoint(%v): %v", chanInfo.ChannelPoint,
1677+
err)
1678+
}
1679+
1680+
pubStr := string(channelPeer.PubKeyBytes[:])
16621681

1663-
// Add all unique addresses from channel graph/NodeAnnouncements
1664-
// to the list of addresses we'll connect to for this peer.
1682+
// Add all unique addresses from channel
1683+
// graph/NodeAnnouncements to the list of addresses we'll
1684+
// connect to for this peer.
16651685
addrSet := make(map[string]net.Addr)
1666-
for _, addr := range policy.Node.Addresses {
1686+
for _, addr := range channelPeer.Addresses {
16671687
switch addr.(type) {
16681688
case *net.TCPAddr:
16691689
addrSet[addr.String()] = addr
@@ -1705,7 +1725,7 @@ func (s *server) establishPersistentConnections() error {
17051725
n := &nodeAddresses{
17061726
addresses: addrs,
17071727
}
1708-
n.pubKey, err = policy.Node.PubKey()
1728+
n.pubKey, err = channelPeer.PubKey()
17091729
if err != nil {
17101730
return err
17111731
}

0 commit comments

Comments
 (0)