parent
73cc28d5fb
commit
98ef563f40
11
server.go
11
server.go
@ -769,15 +769,15 @@ func (s *server) handleConnectPeer(msg *connectPeerMsg) {
|
|||||||
// workflow.
|
// workflow.
|
||||||
func (s *server) handleOpenChanReq(req *openChanReq) {
|
func (s *server) handleOpenChanReq(req *openChanReq) {
|
||||||
var (
|
var (
|
||||||
targetPeer *peer
|
targetPeer *peer
|
||||||
pubStr string
|
pubKeyBytes []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
// If the user is targeting the peer by public key, then we'll need to
|
// If the user is targeting the peer by public key, then we'll need to
|
||||||
// convert that into a string for our map. Otherwise, we expect them to
|
// convert that into a string for our map. Otherwise, we expect them to
|
||||||
// target by peer ID instead.
|
// target by peer ID instead.
|
||||||
if req.targetPubkey != nil {
|
if req.targetPubkey != nil {
|
||||||
pubStr = string(req.targetPubkey.SerializeCompressed())
|
pubKeyBytes = req.targetPubkey.SerializeCompressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
// First attempt to locate the target peer to open a channel with, if
|
// First attempt to locate the target peer to open a channel with, if
|
||||||
@ -785,15 +785,14 @@ func (s *server) handleOpenChanReq(req *openChanReq) {
|
|||||||
s.peersMtx.RLock()
|
s.peersMtx.RLock()
|
||||||
if peer, ok := s.peersByID[req.targetPeerID]; ok {
|
if peer, ok := s.peersByID[req.targetPeerID]; ok {
|
||||||
targetPeer = peer
|
targetPeer = peer
|
||||||
} else if peer, ok := s.peersByPub[pubStr]; ok {
|
} else if peer, ok := s.peersByPub[string(pubKeyBytes)]; ok {
|
||||||
targetPeer = peer
|
targetPeer = peer
|
||||||
}
|
}
|
||||||
s.peersMtx.RUnlock()
|
s.peersMtx.RUnlock()
|
||||||
|
|
||||||
if targetPeer == nil {
|
if targetPeer == nil {
|
||||||
req.err <- fmt.Errorf("unable to find peer nodeID(%x), "+
|
req.err <- fmt.Errorf("unable to find peer nodeID(%x), "+
|
||||||
"peerID(%v)", req.targetPubkey.SerializeCompressed(),
|
"peerID(%v)", pubKeyBytes, req.targetPeerID)
|
||||||
req.targetPeerID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user