mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-17 13:06:14 +02:00
channeldb: drop unused kvdb.RTx parameter from FetchChannelByID
All four call sites pass nil for tx today (server.go, two in channeldb/db_test.go, funding/manager_test.go). The internal channelScanner(nil, selector) call inside FetchChannelByID is preserved verbatim, so runtime behavior is unchanged. This is a prerequisite for the upcoming chanstate.ChannelStore interface: keeping the parameter would leak kvdb into a domain interface.
This commit is contained in:
parent
50eb0d1466
commit
bb8eeb2304
4 changed files with 7 additions and 10 deletions
|
|
@ -729,9 +729,8 @@ func (c *ChannelStateDB) FetchChannel(chanPoint wire.OutPoint) (*OpenChannel,
|
|||
|
||||
// FetchChannelByID attempts to locate a channel specified by the passed channel
|
||||
// ID. If the channel cannot be found, then an error will be returned.
|
||||
// Optionally an existing db tx can be supplied.
|
||||
func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
|
||||
*OpenChannel, error) {
|
||||
func (c *ChannelStateDB) FetchChannelByID(id lnwire.ChannelID) (*OpenChannel,
|
||||
error) {
|
||||
|
||||
selector := func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
|
||||
error) {
|
||||
|
|
@ -774,7 +773,7 @@ func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
|
|||
return targetChanPointBytes, targetChanPoint, nil
|
||||
}
|
||||
|
||||
return c.channelScanner(tx, selector)
|
||||
return c.channelScanner(nil, selector)
|
||||
}
|
||||
|
||||
// ChanCount is used by the server in determining access control.
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ func TestFetchChannel(t *testing.T) {
|
|||
|
||||
// Next, attempt to fetch the channel by its channel ID.
|
||||
chanID := lnwire.NewChanIDFromOutPoint(channelState.FundingOutpoint)
|
||||
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
|
||||
dbChannel, err = cdb.FetchChannelByID(chanID)
|
||||
require.NoError(t, err, "unable to fetch channel")
|
||||
|
||||
// The decoded channel state should be identical to what we stored
|
||||
|
|
@ -272,7 +272,7 @@ func TestFetchChannel(t *testing.T) {
|
|||
require.ErrorIs(t, err, ErrChannelNotFound)
|
||||
|
||||
chanID2 := lnwire.NewChanIDFromOutPoint(channelState2.FundingOutpoint)
|
||||
_, err = cdb.FetchChannelByID(nil, chanID2)
|
||||
_, err = cdb.FetchChannelByID(chanID2)
|
||||
require.ErrorIs(t, err, ErrChannelNotFound)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1118,7 +1118,7 @@ func assertConfirmationHeight(t *testing.T, node *testNode,
|
|||
|
||||
err := wait.NoError(func() error {
|
||||
pendingChannel, err := node.fundingMgr.cfg.Wallet.Cfg.Database.
|
||||
FetchChannelByID(nil, chanID)
|
||||
FetchChannelByID(chanID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to fetch pending channel: %w",
|
||||
err)
|
||||
|
|
|
|||
|
|
@ -1760,9 +1760,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
|
|||
commitHeight uint64) (*lnwallet.BreachRetribution,
|
||||
channeldb.ChannelType, error) {
|
||||
|
||||
channel, err := s.chanStateDB.FetchChannelByID(
|
||||
nil, chanID,
|
||||
)
|
||||
channel, err := s.chanStateDB.FetchChannelByID(chanID)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue