mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-02 13:42:15 +02:00
channeldb+routing: add tx parameter
Adds an optional tx parameter to ForAllOutgoingChannels and FetchChannel so that data can be queried within the context of an existing database transaction.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
)
|
||||
|
||||
// LiveChannelSource is an interface that allows us to query for the set of
|
||||
@@ -17,8 +18,9 @@ type LiveChannelSource interface {
|
||||
FetchAllChannels() ([]*channeldb.OpenChannel, error)
|
||||
|
||||
// FetchChannel attempts to locate a live channel identified by the
|
||||
// passed chanPoint.
|
||||
FetchChannel(chanPoint wire.OutPoint) (*channeldb.OpenChannel, error)
|
||||
// passed chanPoint. Optionally an existing db tx can be supplied.
|
||||
FetchChannel(tx kvdb.RTx, chanPoint wire.OutPoint) (
|
||||
*channeldb.OpenChannel, error)
|
||||
|
||||
// AddrsForNode returns all known addresses for the target node public
|
||||
// key.
|
||||
@@ -55,7 +57,7 @@ func FetchBackupForChan(chanPoint wire.OutPoint,
|
||||
|
||||
// First, we'll query the channel source to see if the channel is known
|
||||
// and open within the database.
|
||||
targetChan, err := chanSource.FetchChannel(chanPoint)
|
||||
targetChan, err := chanSource.FetchChannel(nil, chanPoint)
|
||||
if err != nil {
|
||||
// If we can't find the channel, then we return with an error,
|
||||
// as we have nothing to backup.
|
||||
|
Reference in New Issue
Block a user