lnwallet: remove BlockChainIO as a dependency to LightningChannel

This commit removes the BlockChainIO interface as a dependency to the
LightningChannel struct as the interface is no longer used within the
operation of the LightningChannel.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-02-02 17:05:40 -08:00
1 parent aeb7cce7c3
commit f4b403679b
5 files changed
+17 -17

No files matched your search

+2 -5
View File
@@ -5,6 +5,7 @@ import (
"container/list"
"fmt"
"sync"
"sync/atomic"
"github.com/btcsuite/fastsha256"
"github.com/davecgh/go-spew/spew"
@@ -344,8 +345,6 @@ type LightningChannel struct {
signer Signer
signDesc *SignDescriptor
bio BlockChainIO
channelEvents chainntnfs.ChainNotifier
sync.RWMutex
@@ -454,13 +453,11 @@ type LightningChannel struct {
// settled channel state. Throughout state transitions, then channel will
// automatically persist pertinent state to the database in an efficient
// manner.
func NewLightningChannel(signer Signer, bio BlockChainIO,
events chainntnfs.ChainNotifier,
func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
state *channeldb.OpenChannel) (*LightningChannel, error) {
lc := &LightningChannel{
signer: signer,
bio: bio,
channelEvents: events,
currentHeight: state.NumUpdates,
remoteCommitChain: newCommitmentChain(state.NumUpdates),
+4 -4
View File
@@ -308,11 +308,11 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
notifier := &mockNotfier{}
channelAlice, err := NewLightningChannel(aliceSigner, nil, notifier, aliceChannelState)
channelAlice, err := NewLightningChannel(aliceSigner, notifier, aliceChannelState)
if err != nil {
return nil, nil, nil, err
}
channelBob, err := NewLightningChannel(bobSigner, nil, notifier, bobChannelState)
channelBob, err := NewLightningChannel(bobSigner, notifier, bobChannelState)
if err != nil {
return nil, nil, nil, err
}
@@ -1052,11 +1052,11 @@ func TestStateUpdatePersistence(t *testing.T) {
t.Fatalf("unable to fetch channel: %v", err)
}
notifier := aliceChannel.channelEvents
aliceChannelNew, err := NewLightningChannel(aliceChannel.signer, nil, notifier, aliceChannels[0])
aliceChannelNew, err := NewLightningChannel(aliceChannel.signer, notifier, aliceChannels[0])
if err != nil {
t.Fatalf("unable to create new channel: %v", err)
}
bobChannelNew, err := NewLightningChannel(bobChannel.signer, nil, notifier, bobChannels[0])
bobChannelNew, err := NewLightningChannel(bobChannel.signer, notifier, bobChannels[0])
if err != nil {
t.Fatalf("unable to create new channel: %v", err)
}
+2 -2
View File
@@ -1230,7 +1230,7 @@ func (l *LightningWallet) handleChannelOpen(req *channelOpenMsg) {
// Finally, create and officially open the payment channel!
// TODO(roasbeef): CreationTime once tx is 'open'
channel, err := NewLightningChannel(l.Signer, l.ChainIO, l.chainNotifier,
channel, err := NewLightningChannel(l.Signer, l.chainNotifier,
res.partialState)
if err != nil {
req.err <- err
@@ -1285,7 +1285,7 @@ out:
// Finally, create and officially open the payment channel!
// TODO(roasbeef): CreationTime once tx is 'open'
channel, err := NewLightningChannel(l.Signer, l.ChainIO, l.chainNotifier,
channel, err := NewLightningChannel(l.Signer, l.chainNotifier,
res.partialState)
if err != nil {
res.chanOpenErr <- err