Skip to content

Commit 8315b71

Browse files
committed
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, which the precedent set by invoices/, payments/db/, and graph/db/ explicitly avoids.
1 parent 6fd5b7b commit 8315b71

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

channeldb/db.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,8 @@ func (c *ChannelStateDB) FetchChannel(chanPoint wire.OutPoint) (*OpenChannel,
729729

730730
// FetchChannelByID attempts to locate a channel specified by the passed channel
731731
// ID. If the channel cannot be found, then an error will be returned.
732-
// Optionally an existing db tx can be supplied.
733-
func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
734-
*OpenChannel, error) {
732+
func (c *ChannelStateDB) FetchChannelByID(id lnwire.ChannelID) (*OpenChannel,
733+
error) {
735734

736735
selector := func(chainBkt walletdb.ReadBucket) ([]byte, *wire.OutPoint,
737736
error) {
@@ -774,7 +773,7 @@ func (c *ChannelStateDB) FetchChannelByID(tx kvdb.RTx, id lnwire.ChannelID) (
774773
return targetChanPointBytes, targetChanPoint, nil
775774
}
776775

777-
return c.channelScanner(tx, selector)
776+
return c.channelScanner(nil, selector)
778777
}
779778

780779
// ChanCount is used by the server in determining access control.

channeldb/db_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestFetchChannel(t *testing.T) {
253253

254254
// Next, attempt to fetch the channel by its channel ID.
255255
chanID := lnwire.NewChanIDFromOutPoint(channelState.FundingOutpoint)
256-
dbChannel, err = cdb.FetchChannelByID(nil, chanID)
256+
dbChannel, err = cdb.FetchChannelByID(chanID)
257257
require.NoError(t, err, "unable to fetch channel")
258258

259259
// The decoded channel state should be identical to what we stored
@@ -272,7 +272,7 @@ func TestFetchChannel(t *testing.T) {
272272
require.ErrorIs(t, err, ErrChannelNotFound)
273273

274274
chanID2 := lnwire.NewChanIDFromOutPoint(channelState2.FundingOutpoint)
275-
_, err = cdb.FetchChannelByID(nil, chanID2)
275+
_, err = cdb.FetchChannelByID(chanID2)
276276
require.ErrorIs(t, err, ErrChannelNotFound)
277277
}
278278

funding/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ func assertConfirmationHeight(t *testing.T, node *testNode,
11181118

11191119
err := wait.NoError(func() error {
11201120
pendingChannel, err := node.fundingMgr.cfg.Wallet.Cfg.Database.
1121-
FetchChannelByID(nil, chanID)
1121+
FetchChannelByID(chanID)
11221122
if err != nil {
11231123
return fmt.Errorf("unable to fetch pending channel: %w",
11241124
err)

server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,9 +1760,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
17601760
commitHeight uint64) (*lnwallet.BreachRetribution,
17611761
channeldb.ChannelType, error) {
17621762

1763-
channel, err := s.chanStateDB.FetchChannelByID(
1764-
nil, chanID,
1765-
)
1763+
channel, err := s.chanStateDB.FetchChannelByID(chanID)
17661764
if err != nil {
17671765
return nil, 0, err
17681766
}

0 commit comments

Comments
 (0)