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

NewChainService does not traverse through all supplied Neutrino Peers before returning with error #60

Open
biscottigelato opened this issue May 29, 2018 · 1 comment

Comments

@biscottigelato
Copy link

biscottigelato commented May 29, 2018

With multiple neutrino peers supplied through lnd.conf/neutrino.Config structure, it seems that NewChainService() will try to resolve the peers' addresses and try to connect to them. However as soon as one of these addresses are deemed invalid, NewChainService() stops attempting and simply returns with error immediately, without trying the remaining peer addresses.

At first glance it can be a fairly trivial change to remedy this? But not sure if there are other implications, like whether the neutrino.Config structure should be updated to remove the invalid addresses, etc.

        // Start up persistent peers.
	permanentPeers := cfg.ConnectPeers
	if len(permanentPeers) == 0 {
		permanentPeers = cfg.AddPeers
	}

	var peerConnErr error
	var peersConnected int

	for _, addr := range permanentPeers {
		tcpAddr, err := s.addrStringToNetAddr(addr)

		if err != nil {
			peerConnErr = err
		} else {
			peersConnected++
			go s.connManager.Connect(&connmgr.ConnReq{
				Addr:      tcpAddr,
				Permanent: true,
			})
		}
	}

	if peersConnected != 0 {
		peerConnErr = nil
	}

	return &s, peerConnErr

I can create a Pull Request if this seems like that right direction to go?

@Roasbeef
Copy link
Member

Approach looks sound if you still want to pick this up. Atm, it's implemented more as an "all or nothing". I think this is also related to lightningnetwork/lnd#4016

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

No branches or pull requests

2 participants