@@ -18,6 +18,7 @@ import (
18
18
"github.com/btcsuite/btcd/chaincfg/chainhash"
19
19
"github.com/btcsuite/btcd/txscript"
20
20
"github.com/btcsuite/btcd/wire"
21
+ "github.com/btcsuite/btcwallet/walletdb"
21
22
"github.com/lightningnetwork/lnd/aliasmgr"
22
23
"github.com/lightningnetwork/lnd/batch"
23
24
"github.com/lightningnetwork/lnd/graph/db/models"
@@ -3895,29 +3896,16 @@ func (c *ChannelGraph) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
3895
3896
// the graph cache is not enabled, then the call-back will be provided with
3896
3897
// access to the graph via a consistent read-only transaction.
3897
3898
func (c * ChannelGraph ) GraphSession (cb func (graph NodeTraverser ) error ) error {
3898
- var (
3899
- tx kvdb.RTx
3900
- err error
3901
- commit = func () {}
3902
- )
3903
- if c .graphCache == nil {
3904
- tx , err = c .db .BeginReadTx ()
3905
- if err != nil {
3906
- return err
3907
- }
3908
-
3909
- commit = func () {
3910
- if err := tx .Rollback (); err != nil {
3911
- log .Errorf ("Unable to rollback tx: %v" , err )
3912
- }
3913
- }
3899
+ if c .graphCache != nil {
3900
+ return cb (& nodeTraverserSession {db : c })
3914
3901
}
3915
- defer commit ()
3916
3902
3917
- return cb (& nodeTraverserSession {
3918
- db : c ,
3919
- tx : tx ,
3920
- })
3903
+ return c .db .View (func (tx walletdb.ReadTx ) error {
3904
+ return cb (& nodeTraverserSession {
3905
+ db : c ,
3906
+ tx : tx ,
3907
+ })
3908
+ }, func () {})
3921
3909
}
3922
3910
3923
3911
// nodeTraverserSession implements the NodeTraverser interface but with a
0 commit comments