Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if peer is already connected #403

Merged
merged 2 commits into from
Aug 6, 2024
Merged

fix: check if peer is already connected #403

merged 2 commits into from
Aug 6, 2024

Conversation

im-adithya
Copy link
Member

Fixes #394

Checks if the peer is already connected, and returns nil

@im-adithya im-adithya requested review from bumi and rolznz August 5, 2024 16:25
@bumi
Copy link
Contributor

bumi commented Aug 5, 2024

can we catch the error? then we don't have to always do two calls? because this now takes double the time and it doubles the things that can go wrong.
if the error is that a peer is already connected we treat it as success.

@bumi
Copy link
Contributor

bumi commented Aug 5, 2024

utACK

@rolznz
Copy link
Contributor

rolznz commented Aug 6, 2024

I think this is quite fragile error handling:

if grpcErr, ok := status.FromError(err); ok {
		if strings.HasPrefix(grpcErr.Message(), "already connected to peer") {
			return nil
		}
	}

If the error message changes slightly this could break again. Does this particular error have a specific code we can use?

@im-adithya
Copy link
Member Author

The code we get is codes.Unknown, LND doesn't give any specific errors sadly

Copy link
Contributor

@rolznz rolznz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@rolznz rolznz merged commit 7e8e217 into master Aug 6, 2024
8 checks passed
@rolznz rolznz deleted the task-lnd-peer branch August 6, 2024 06:26
@bumi
Copy link
Contributor

bumi commented Aug 6, 2024

I think this is quite fragile error handling:

I said and think this is OK. because I think it's better than doing a second request to look for the peers with all the addtional error cases and we don't have a code to identify it and I don't think the message changes likely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LND connect peer fails if the peer is already connected
3 participants