lnd: add new "perm" bit to the ConnectPeer RPC call

This commit modifies the ConnectPeer RPC call and partitions the
behavior of the call into two scenarios: the connection should be
persistent which causes the call to be non-blocking, and the connection
should only attempt to connect once — which causes the call to be
blocking and report any error back to the caller.

As a result, the pendingConnRequest map and the logic around it is no
longer needed.
This commit is contained in:
Olaoluwa Osuntokun
2017-01-09 19:08:52 -08:00
parent b01e7efcef
commit 8cdb84c619
3 changed files with 42 additions and 59 deletions

View File

@ -215,15 +215,13 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
ChainNet: activeNetParams.Net,
}
peerID, err := r.server.ConnectToPeer(peerAddr)
if err != nil {
if err := r.server.ConnectToPeer(peerAddr, in.Perm); err != nil {
rpcsLog.Errorf("(connectpeer): error connecting to peer: %v", err)
return nil, err
}
// TODO(roasbeef): add pubkey return
rpcsLog.Debugf("Connected to peer: %v", peerAddr.String())
return &lnrpc.ConnectPeerResponse{peerID}, nil
return &lnrpc.ConnectPeerResponse{}, nil
}
// OpenChannel attempts to open a singly funded channel specified in the