multi: remove returned error from WipeChannel
The linter complains about not checking the return value from WipeChannel in certain places. Instead of checking we simply remove the returned error because the in-memory modifications cannot fail.
This commit is contained in:
parent
9385b8cdc6
commit
ec784db511
@ -45,8 +45,8 @@ func (p *mockPeer) SendMessageLazy(sync bool, msgs ...lnwire.Message) error {
|
|||||||
func (p *mockPeer) AddNewChannel(_ *channeldb.OpenChannel, _ <-chan struct{}) error {
|
func (p *mockPeer) AddNewChannel(_ *channeldb.OpenChannel, _ <-chan struct{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (p *mockPeer) WipeChannel(_ *wire.OutPoint) error { return nil }
|
func (p *mockPeer) WipeChannel(_ *wire.OutPoint) {}
|
||||||
func (p *mockPeer) IdentityKey() *btcec.PublicKey { return p.pk }
|
func (p *mockPeer) IdentityKey() *btcec.PublicKey { return p.pk }
|
||||||
func (p *mockPeer) PubKey() [33]byte {
|
func (p *mockPeer) PubKey() [33]byte {
|
||||||
var pubkey [33]byte
|
var pubkey [33]byte
|
||||||
copy(pubkey[:], p.pk.SerializeCompressed())
|
copy(pubkey[:], p.pk.SerializeCompressed())
|
||||||
|
@ -201,9 +201,7 @@ func (n *testNode) SendMessageLazy(sync bool, msgs ...lnwire.Message) error {
|
|||||||
return n.SendMessage(sync, msgs...)
|
return n.SendMessage(sync, msgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *testNode) WipeChannel(_ *wire.OutPoint) error {
|
func (n *testNode) WipeChannel(_ *wire.OutPoint) {}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *testNode) QuitSignal() <-chan struct{} {
|
func (n *testNode) QuitSignal() <-chan struct{} {
|
||||||
return n.shutdownChannel
|
return n.shutdownChannel
|
||||||
|
@ -1084,11 +1084,7 @@ out:
|
|||||||
// TODO(roasbeef): remove all together
|
// TODO(roasbeef): remove all together
|
||||||
go func() {
|
go func() {
|
||||||
chanPoint := l.channel.ChannelPoint()
|
chanPoint := l.channel.ChannelPoint()
|
||||||
err := l.cfg.Peer.WipeChannel(chanPoint)
|
l.cfg.Peer.WipeChannel(chanPoint)
|
||||||
if err != nil {
|
|
||||||
l.log.Errorf("unable to wipe channel "+
|
|
||||||
"%v", err)
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
break out
|
break out
|
||||||
|
@ -1652,9 +1652,7 @@ func (m *mockPeer) AddNewChannel(_ *channeldb.OpenChannel,
|
|||||||
_ <-chan struct{}) error {
|
_ <-chan struct{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (m *mockPeer) WipeChannel(*wire.OutPoint) error {
|
func (m *mockPeer) WipeChannel(*wire.OutPoint) {}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (m *mockPeer) PubKey() [33]byte {
|
func (m *mockPeer) PubKey() [33]byte {
|
||||||
return [33]byte{}
|
return [33]byte{}
|
||||||
}
|
}
|
||||||
|
@ -602,9 +602,7 @@ func (s *mockServer) AddNewChannel(channel *channeldb.OpenChannel,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *mockServer) WipeChannel(*wire.OutPoint) error {
|
func (s *mockServer) WipeChannel(*wire.OutPoint) {}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *mockServer) LocalFeatures() *lnwire.FeatureVector {
|
func (s *mockServer) LocalFeatures() *lnwire.FeatureVector {
|
||||||
return nil
|
return nil
|
||||||
|
@ -30,7 +30,7 @@ type Peer interface {
|
|||||||
|
|
||||||
// WipeChannel removes the channel uniquely identified by its channel
|
// WipeChannel removes the channel uniquely identified by its channel
|
||||||
// point from all indexes associated with the peer.
|
// point from all indexes associated with the peer.
|
||||||
WipeChannel(*wire.OutPoint) error
|
WipeChannel(*wire.OutPoint)
|
||||||
|
|
||||||
// PubKey returns the serialized public key of the remote peer.
|
// PubKey returns the serialized public key of the remote peer.
|
||||||
PubKey() [33]byte
|
PubKey() [33]byte
|
||||||
|
24
peer.go
24
peer.go
@ -2401,13 +2401,7 @@ func (p *peer) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
|||||||
// TODO(roasbeef): no longer need with newer beach logic?
|
// TODO(roasbeef): no longer need with newer beach logic?
|
||||||
peerLog.Infof("ChannelPoint(%v) has been breached, wiping "+
|
peerLog.Infof("ChannelPoint(%v) has been breached, wiping "+
|
||||||
"channel", req.ChanPoint)
|
"channel", req.ChanPoint)
|
||||||
if err := p.WipeChannel(req.ChanPoint); err != nil {
|
p.WipeChannel(req.ChanPoint)
|
||||||
peerLog.Infof("Unable to wipe channel after detected "+
|
|
||||||
"breach: %v", err)
|
|
||||||
req.Err <- err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2434,11 +2428,7 @@ func (p *peer) handleLinkFailure(failure linkFailureReport) {
|
|||||||
// link and cancel back any adds in its mailboxes such that we can
|
// link and cancel back any adds in its mailboxes such that we can
|
||||||
// safely force close without the link being added again and updates
|
// safely force close without the link being added again and updates
|
||||||
// being applied.
|
// being applied.
|
||||||
if err := p.WipeChannel(&failure.chanPoint); err != nil {
|
p.WipeChannel(&failure.chanPoint)
|
||||||
peerLog.Errorf("Unable to wipe link for chanpoint=%v",
|
|
||||||
failure.chanPoint)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the error encountered was severe enough, we'll now force close the
|
// If the error encountered was severe enough, we'll now force close the
|
||||||
// channel to prevent readding it to the switch in the future.
|
// channel to prevent readding it to the switch in the future.
|
||||||
@ -2490,11 +2480,7 @@ func (p *peer) finalizeChanClosure(chanCloser *channelCloser) {
|
|||||||
|
|
||||||
// First, we'll clear all indexes related to the channel in question.
|
// First, we'll clear all indexes related to the channel in question.
|
||||||
chanPoint := chanCloser.cfg.channel.ChannelPoint()
|
chanPoint := chanCloser.cfg.channel.ChannelPoint()
|
||||||
if err := p.WipeChannel(chanPoint); err != nil {
|
p.WipeChannel(chanPoint)
|
||||||
if closeReq != nil {
|
|
||||||
closeReq.Err <- err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, we'll launch a goroutine which will request to be notified by
|
// Next, we'll launch a goroutine which will request to be notified by
|
||||||
// the ChainNotifier once the closure transaction obtains a single
|
// the ChainNotifier once the closure transaction obtains a single
|
||||||
@ -2584,7 +2570,7 @@ func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
|
|||||||
|
|
||||||
// WipeChannel removes the passed channel point from all indexes associated with
|
// WipeChannel removes the passed channel point from all indexes associated with
|
||||||
// the peer, and the switch.
|
// the peer, and the switch.
|
||||||
func (p *peer) WipeChannel(chanPoint *wire.OutPoint) error {
|
func (p *peer) WipeChannel(chanPoint *wire.OutPoint) {
|
||||||
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
chanID := lnwire.NewChanIDFromOutPoint(chanPoint)
|
||||||
|
|
||||||
p.activeChanMtx.Lock()
|
p.activeChanMtx.Lock()
|
||||||
@ -2594,8 +2580,6 @@ func (p *peer) WipeChannel(chanPoint *wire.OutPoint) error {
|
|||||||
// Instruct the HtlcSwitch to close this link as the channel is no
|
// Instruct the HtlcSwitch to close this link as the channel is no
|
||||||
// longer active.
|
// longer active.
|
||||||
p.server.htlcSwitch.RemoveLink(chanID)
|
p.server.htlcSwitch.RemoveLink(chanID)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleInitMsg handles the incoming init message which contains global and
|
// handleInitMsg handles the incoming init message which contains global and
|
||||||
|
@ -2259,10 +2259,7 @@ func (r *rpcServer) AbandonChannel(ctx context.Context,
|
|||||||
}
|
}
|
||||||
remotePub := dbChan.IdentityPub
|
remotePub := dbChan.IdentityPub
|
||||||
if peer, err := r.server.FindPeer(remotePub); err == nil {
|
if peer, err := r.server.FindPeer(remotePub); err == nil {
|
||||||
if err := peer.WipeChannel(chanPoint); err != nil {
|
peer.WipeChannel(chanPoint)
|
||||||
return nil, fmt.Errorf("unable to wipe "+
|
|
||||||
"channel state: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user