htlcswitch: update WipeChannel on Peer interface to simply take the chanPoint

The WipeChannel method doesn’t need to take the channel itself, as any
relevant indexes should be able to be queried based on the channel
point along.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-23 01:15:21 -06:00
parent 3aabbce551
commit 25082f0b5b
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
4 changed files with 10 additions and 8 deletions

@ -2,9 +2,9 @@ package htlcswitch
import ( import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
) )
// InvoiceDatabase is an interface which represents the persistent subsystem // InvoiceDatabase is an interface which represents the persistent subsystem
@ -97,9 +97,9 @@ type Peer interface {
// SendMessage sends message to remote peer. // SendMessage sends message to remote peer.
SendMessage(lnwire.Message) error SendMessage(lnwire.Message) error
// WipeChannel removes the passed channel from all indexes associated // WipeChannel removes the channel uniquely identified by its channel
// with the peer. // point from all indexes associated with the peer.
WipeChannel(*lnwallet.LightningChannel) error WipeChannel(*wire.OutPoint) error
// PubKey returns the serialize public key of the source peer. // PubKey returns the serialize public key of the source peer.
PubKey() [33]byte PubKey() [33]byte

@ -422,13 +422,14 @@ out:
// TODO(roasbeef): remove all together // TODO(roasbeef): remove all together
go func() { go func() {
if err := l.cfg.Peer.WipeChannel(l.channel); err != nil { chanPoint := l.channel.ChannelPoint()
if err := l.cfg.Peer.WipeChannel(chanPoint); err != nil {
log.Errorf("unable to wipe channel %v", err) log.Errorf("unable to wipe channel %v", err)
} }
// TODO(roasbeef): need to send HTLC outputs to nursery // TODO(roasbeef): need to send HTLC outputs to nursery
// TODO(roasbeef): or let the arb sweep? // TODO(roasbeef): or let the arb sweep?
l.cfg.SettledContracts <- l.channel.ChannelPoint() l.cfg.SettledContracts <- chanPoint
}() }()
break out break out

@ -20,6 +20,7 @@ import (
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil" "github.com/roasbeef/btcutil"
) )
@ -1396,7 +1397,7 @@ func (m *mockPeer) SendMessage(msg lnwire.Message) error {
m.Unlock() m.Unlock()
return nil return nil
} }
func (m *mockPeer) WipeChannel(*lnwallet.LightningChannel) error { func (m *mockPeer) WipeChannel(*wire.OutPoint) error {
return nil return nil
} }
func (m *mockPeer) PubKey() [33]byte { func (m *mockPeer) PubKey() [33]byte {

@ -332,7 +332,7 @@ func (s *mockServer) Disconnect(reason error) {
s.t.Fatalf("server %v was disconnected: %v", s.name, reason) s.t.Fatalf("server %v was disconnected: %v", s.name, reason)
} }
func (s *mockServer) WipeChannel(*lnwallet.LightningChannel) error { func (s *mockServer) WipeChannel(*wire.OutPoint) error {
return nil return nil
} }