Merge pull request #4055 from cfromknecht/remove-failed-channels

peer: remove unused failedChannels channels map
This commit is contained in:
Conner Fromknecht 2020-03-06 16:50:57 -08:00 committed by GitHub
commit ecf7d82904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

26
peer.go

@ -210,14 +210,6 @@ type peer struct {
// the connection handshake. // the connection handshake.
remoteFeatures *lnwire.FeatureVector remoteFeatures *lnwire.FeatureVector
// failedChannels is a set that tracks channels we consider `failed`.
// This is a temporary measure until we have implemented real failure
// handling at the link level, to handle the case where we reconnect to
// a peer and try to re-sync a failed channel, triggering a disconnect
// loop.
// TODO(halseth): remove when link failure is properly handled.
failedChannels map[lnwire.ChannelID]struct{}
// writePool is the task pool to that manages reuse of write buffers. // writePool is the task pool to that manages reuse of write buffers.
// Write tasks are submitted to the pool in order to conserve the total // Write tasks are submitted to the pool in order to conserve the total
// number of write buffers allocated at any one time, and decouple write // number of write buffers allocated at any one time, and decouple write
@ -274,7 +266,6 @@ func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server,
localCloseChanReqs: make(chan *htlcswitch.ChanClose), localCloseChanReqs: make(chan *htlcswitch.ChanClose),
linkFailures: make(chan linkFailureReport), linkFailures: make(chan linkFailureReport),
chanCloseMsgs: make(chan *closeMsg), chanCloseMsgs: make(chan *closeMsg),
failedChannels: make(map[lnwire.ChannelID]struct{}),
chanActiveTimeout: chanActiveTimeout, chanActiveTimeout: chanActiveTimeout,
@ -488,14 +479,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) (
continue continue
} }
// Also skip adding any channel marked as `failed` for this
// session.
if _, ok := p.failedChannels[chanID]; ok {
peerLog.Warnf("ChannelPoint(%v) is failed, won't "+
"start.", chanPoint)
continue
}
_, currentHeight, err := p.server.cc.chainIO.GetBestBlock() _, currentHeight, err := p.server.cc.chainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, err return nil, err
@ -1203,12 +1186,8 @@ func (p *peer) handleError(msg *lnwire.Error) bool {
// In the case of an all-zero channel ID we want to forward the error to // In the case of an all-zero channel ID we want to forward the error to
// all channels with this peer. // all channels with this peer.
case msg.ChanID == lnwire.ConnectionWideID: case msg.ChanID == lnwire.ConnectionWideID:
for chanID, chanStream := range p.activeMsgStreams { for _, chanStream := range p.activeMsgStreams {
chanStream.AddMsg(msg) chanStream.AddMsg(msg)
// Also marked this channel as failed, so we won't try
// to restart it on reconnect with this peer.
p.failedChannels[chanID] = struct{}{}
} }
return false return false
@ -1220,9 +1199,6 @@ func (p *peer) handleError(msg *lnwire.Error) bool {
// If not we hand the error to the channel link for this channel. // If not we hand the error to the channel link for this channel.
case p.isActiveChannel(msg.ChanID): case p.isActiveChannel(msg.ChanID):
// Mark this channel as failed, so we won't try to restart it on
// reconnect with this peer.
p.failedChannels[msg.ChanID] = struct{}{}
return true return true
default: default: