Skip to content

Commit d10ab03

Browse files
authored
Merge pull request #9480 from ellemouton/autopilotRefactor
graph+autopilot: remove `autopilot` access to raw `graphdb.ChannelGraph`
2 parents 2a0dca7 + 3d0ae96 commit d10ab03

File tree

11 files changed

+537
-417
lines changed

11 files changed

+537
-417
lines changed

autopilot/graph.go

Lines changed: 37 additions & 382 deletions
Large diffs are not rendered by default.

autopilot/interface.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"github.com/btcsuite/btcd/btcec/v2"
77
"github.com/btcsuite/btcd/btcutil"
88
"github.com/btcsuite/btcd/wire"
9+
graphdb "github.com/lightningnetwork/lnd/graph/db"
910
"github.com/lightningnetwork/lnd/lnwire"
11+
"github.com/lightningnetwork/lnd/routing/route"
1012
)
1113

1214
// DefaultConfTarget is the default confirmation target for autopilot channels.
@@ -216,3 +218,20 @@ type ChannelController interface {
216218
// TODO(roasbeef): add force option?
217219
CloseChannel(chanPoint *wire.OutPoint) error
218220
}
221+
222+
// GraphSource represents read access to the channel graph.
223+
type GraphSource interface {
224+
// ForEachNode iterates through all the stored vertices/nodes in the
225+
// graph, executing the passed callback with each node encountered. If
226+
// the callback returns an error, then the transaction is aborted and
227+
// the iteration stops early. Any operations performed on the NodeTx
228+
// passed to the call-back are executed under the same read transaction.
229+
ForEachNode(func(graphdb.NodeRTx) error) error
230+
231+
// ForEachNodeCached is similar to ForEachNode, but it utilizes the
232+
// channel graph cache if one is available. It is less consistent than
233+
// ForEachNode since any further calls are made across multiple
234+
// transactions.
235+
ForEachNodeCached(cb func(node route.Vertex,
236+
chans map[uint64]*graphdb.DirectedChannel) error) error
237+
}

0 commit comments

Comments
 (0)