channeldb/channel: remove unused FullSync method
The exported FullSync method is only used by test code, so we remove it and instead use SyncPending.
This commit is contained in:
parent
b7e1bb0bf0
commit
0122dda88a
@ -514,16 +514,6 @@ type OpenChannel struct {
|
|||||||
sync.RWMutex
|
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.
|
// ShortChanID returns the current ShortChannelID of this channel.
|
||||||
func (c *OpenChannel) ShortChanID() lnwire.ShortChannelID {
|
func (c *OpenChannel) ShortChanID() lnwire.ShortChannelID {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
@ -648,9 +638,8 @@ func fetchChanBucket(tx *bbolt.Tx, nodeKey *btcec.PublicKey,
|
|||||||
return chanBucket, nil
|
return chanBucket, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// fullSync is an internal version of the FullSync method which allows callers
|
// fullSync syncs the contents of an OpenChannel while re-using an existing
|
||||||
// to sync the contents of an OpenChannel while re-using an existing database
|
// database transaction.
|
||||||
// transaction.
|
|
||||||
func (c *OpenChannel) fullSync(tx *bbolt.Tx) error {
|
func (c *OpenChannel) fullSync(tx *bbolt.Tx) error {
|
||||||
// First fetch the top level bucket which stores all data related to
|
// First fetch the top level bucket which stores all data related to
|
||||||
// current, active channels.
|
// current, active channels.
|
||||||
|
@ -263,7 +263,12 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
|
|||||||
OnionBlob: []byte("onionblob"),
|
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)
|
t.Fatalf("unable to save and serialize channel state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +368,12 @@ func TestChannelStateTransition(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create channel state: %v", err)
|
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)
|
t.Fatalf("unable to save and serialize channel state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,12 @@ func TestFetchClosedChannelForID(t *testing.T) {
|
|||||||
for i := uint32(0); i < numChans; i++ {
|
for i := uint32(0); i < numChans; i++ {
|
||||||
// Save the open channel to disk.
|
// Save the open channel to disk.
|
||||||
state.FundingOutpoint.Index = i
|
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 "+
|
t.Fatalf("unable to save and serialize channel "+
|
||||||
"state: %v", err)
|
"state: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
@ -334,10 +335,20 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error)
|
|||||||
return nil, nil, nil, err
|
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
|
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
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user