diff --git a/channeldb/channel.go b/channeldb/channel.go index 2b1ec949..b11e09e8 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -514,16 +514,6 @@ type OpenChannel struct { sync.RWMutex } -// FullSync serializes, and writes to disk the *full* channel state, using -// both the active channel bucket to store the prefixed column fields, and the -// remote node's ID to store the remainder of the channel state. -func (c *OpenChannel) FullSync() error { - c.Lock() - defer c.Unlock() - - return c.Db.Update(c.fullSync) -} - // ShortChanID returns the current ShortChannelID of this channel. func (c *OpenChannel) ShortChanID() lnwire.ShortChannelID { c.RLock() @@ -648,9 +638,8 @@ func fetchChanBucket(tx *bbolt.Tx, nodeKey *btcec.PublicKey, return chanBucket, nil } -// fullSync is an internal version of the FullSync method which allows callers -// to sync the contents of an OpenChannel while re-using an existing database -// transaction. +// fullSync syncs the contents of an OpenChannel while re-using an existing +// database transaction. func (c *OpenChannel) fullSync(tx *bbolt.Tx) error { // First fetch the top level bucket which stores all data related to // current, active channels. diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go index 770f6f35..46ac311c 100644 --- a/channeldb/channel_test.go +++ b/channeldb/channel_test.go @@ -263,7 +263,12 @@ func TestOpenChannelPutGetDelete(t *testing.T) { OnionBlob: []byte("onionblob"), }, } - if err := state.FullSync(); err != nil { + + addr := &net.TCPAddr{ + IP: net.ParseIP("127.0.0.1"), + Port: 18556, + } + if err := state.SyncPending(addr, 101); err != nil { t.Fatalf("unable to save and serialize channel state: %v", err) } @@ -363,7 +368,12 @@ func TestChannelStateTransition(t *testing.T) { if err != nil { t.Fatalf("unable to create channel state: %v", err) } - if err := channel.FullSync(); err != nil { + + addr := &net.TCPAddr{ + IP: net.ParseIP("127.0.0.1"), + Port: 18556, + } + if err := channel.SyncPending(addr, 101); err != nil { t.Fatalf("unable to save and serialize channel state: %v", err) } diff --git a/channeldb/db_test.go b/channeldb/db_test.go index 43b62619..198f6e2b 100644 --- a/channeldb/db_test.go +++ b/channeldb/db_test.go @@ -110,7 +110,12 @@ func TestFetchClosedChannelForID(t *testing.T) { for i := uint32(0); i < numChans; i++ { // Save the open channel to disk. state.FundingOutpoint.Index = i - if err := state.FullSync(); err != nil { + + addr := &net.TCPAddr{ + IP: net.ParseIP("127.0.0.1"), + Port: 18556, + } + if err := state.SyncPending(addr, 101); err != nil { t.Fatalf("unable to save and serialize channel "+ "state: %v", err) } diff --git a/lnwallet/test_utils.go b/lnwallet/test_utils.go index 4dee6ccb..37f13c55 100644 --- a/lnwallet/test_utils.go +++ b/lnwallet/test_utils.go @@ -7,6 +7,7 @@ import ( "encoding/hex" "io" "io/ioutil" + "net" "os" "github.com/btcsuite/btcd/btcec" @@ -334,10 +335,20 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error) return nil, nil, nil, err } - if err := channelAlice.channelState.FullSync(); err != nil { + addr := &net.TCPAddr{ + IP: net.ParseIP("127.0.0.1"), + Port: 18556, + } + if err := channelAlice.channelState.SyncPending(addr, 101); err != nil { return nil, nil, nil, err } - if err := channelBob.channelState.FullSync(); err != nil { + + addr = &net.TCPAddr{ + IP: net.ParseIP("127.0.0.1"), + Port: 18555, + } + + if err := channelBob.channelState.SyncPending(addr, 101); err != nil { return nil, nil, nil, err }