mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-12 02:08:25 +01:00
pilot: if unable to establish channel, disconnect peer
In this commit, we fix a quick in the main autopilot handling. If we’re unable to establish a channel to a peer for w/e reason, then we’ll disconnect the peer. With this tactic, we avoid unnecessarily building up tens of peers for no reason at all.
This commit is contained in:
parent
00ab66469d
commit
602048ae5c
1 changed files with 14 additions and 1 deletions
13
pilot.go
13
pilot.go
|
@ -98,6 +98,18 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
|
// If we were not able to actually open a channel to the peer
|
||||||
|
// for whatever reason, then we'll disconnect from the peer to
|
||||||
|
// ensure we don't accumulate a bunch of unnecessary
|
||||||
|
// connections.
|
||||||
|
if err != nil {
|
||||||
|
dcErr := c.server.DisconnectPeer(target)
|
||||||
|
if dcErr != nil {
|
||||||
|
atplLog.Errorf("Unable to disconnect from peer %v",
|
||||||
|
target.SerializeCompressed())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
case <-updateStream:
|
case <-updateStream:
|
||||||
return nil
|
return nil
|
||||||
|
@ -149,6 +161,7 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
|
||||||
return svr.cc.wallet.ConfirmedBalance(1)
|
return svr.cc.wallet.ConfirmedBalance(1)
|
||||||
},
|
},
|
||||||
Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()),
|
Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()),
|
||||||
|
MaxPendingOpens: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, we'll fetch the current state of open channels from the
|
// Next, we'll fetch the current state of open channels from the
|
||||||
|
|
Loading…
Add table
Reference in a new issue