refactor: move graph related DB code to graph/db from channeldb
This is a pure refactor commit. It moves over all the graph related CRUD code from `channeldb` to `graph/db`.
This commit is contained in:
57 files changed
+512
-299
No files matched your search
@@ -3,8 +3,8 @@ package routing
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -96,7 +96,7 @@ func newBandwidthManager(graph Graph, sourceNode route.Vertex,
|
||||
// First, we'll collect the set of outbound edges from the target
|
||||
// source node and add them to our bandwidth manager's map of channels.
|
||||
err := graph.ForEachNodeChannel(sourceNode,
|
||||
func(channel *channeldb.DirectedChannel) error {
|
||||
func(channel *graphdb.DirectedChannel) error {
|
||||
shortID := lnwire.NewShortChanIDFromInt(
|
||||
channel.ChannelID,
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
)
|
||||
|
||||
// BitcoindFilteredChainView is an implementation of the FilteredChainView
|
||||
@@ -448,7 +448,7 @@ func (b *BitcoindFilteredChainView) chainFilterer() {
|
||||
// rewound to ensure all relevant notifications are dispatched.
|
||||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (b *BitcoindFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
|
||||
func (b *BitcoindFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
|
||||
updateHeight uint32) error {
|
||||
|
||||
newUtxos := make([]wire.OutPoint, len(ops))
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
)
|
||||
|
||||
// BtcdFilteredChainView is an implementation of the FilteredChainView
|
||||
@@ -456,7 +456,7 @@ type filterUpdate struct {
|
||||
// rewound to ensure all relevant notifications are dispatched.
|
||||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (b *BtcdFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
|
||||
func (b *BtcdFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
|
||||
updateHeight uint32) error {
|
||||
|
||||
newUtxos := make([]wire.OutPoint, len(ops))
|
||||
|
||||
@@ -3,7 +3,7 @@ package chainview
|
||||
import (
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
)
|
||||
|
||||
// FilteredChainView represents a subscription to a certain subset of the
|
||||
@@ -43,7 +43,7 @@ type FilteredChainView interface {
|
||||
// relevant notifications are dispatched, meaning blocks with a height
|
||||
// lower than the best known height might be sent over the
|
||||
// FilteredBlocks() channel.
|
||||
UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error
|
||||
UpdateFilter(ops []graphdb.EdgePoint, updateHeight uint32) error
|
||||
|
||||
// FilterBlock takes a block hash, and returns a FilteredBlocks which
|
||||
// is the result of applying the current registered UTXO sub-set on the
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
_ "github.com/btcsuite/btcwallet/walletdb/bdb" // Required to register the boltdb walletdb implementation.
|
||||
"github.com/lightninglabs/neutrino"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lntest/unittest"
|
||||
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||
@@ -218,7 +218,7 @@ func testFilterBlockNotifications(node *rpctest.Harness,
|
||||
require.NoError(t, err, "unable to get current height")
|
||||
|
||||
// Now we'll add both outpoints to the current filter.
|
||||
filter := []channeldb.EdgePoint{
|
||||
filter := []graphdb.EdgePoint{
|
||||
{FundingPkScript: targetScript, OutPoint: *outPoint1},
|
||||
{FundingPkScript: targetScript, OutPoint: *outPoint2},
|
||||
}
|
||||
@@ -328,7 +328,7 @@ func testUpdateFilterBackTrack(node *rpctest.Harness,
|
||||
|
||||
// After the block has been mined+notified we'll update the filter with
|
||||
// a _prior_ height so a "rewind" occurs.
|
||||
filter := []channeldb.EdgePoint{
|
||||
filter := []graphdb.EdgePoint{
|
||||
{FundingPkScript: testScript, OutPoint: *outPoint},
|
||||
}
|
||||
err = chainView.UpdateFilter(filter, uint32(currentHeight))
|
||||
@@ -417,7 +417,7 @@ func testFilterSingleBlock(node *rpctest.Harness, chainView FilteredChainView,
|
||||
|
||||
// Now we'll manually trigger filtering the block generated above.
|
||||
// First, we'll add the two outpoints to our filter.
|
||||
filter := []channeldb.EdgePoint{
|
||||
filter := []graphdb.EdgePoint{
|
||||
{FundingPkScript: testScript, OutPoint: *outPoint1},
|
||||
{FundingPkScript: testScript, OutPoint: *outPoint2},
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/neutrino"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
)
|
||||
|
||||
@@ -320,7 +320,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB
|
||||
// rewound to ensure all relevant notifications are dispatched.
|
||||
//
|
||||
// NOTE: This is part of the FilteredChainView interface.
|
||||
func (c *CfFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint,
|
||||
func (c *CfFilteredChainView) UpdateFilter(ops []graphdb.EdgePoint,
|
||||
updateHeight uint32) error {
|
||||
|
||||
log.Tracef("Updating chain filter with new UTXO's: %v", ops)
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
)
|
||||
@@ -15,7 +15,7 @@ type Graph interface {
|
||||
// ForEachNodeChannel calls the callback for every channel of the given
|
||||
// node.
|
||||
ForEachNodeChannel(nodePub route.Vertex,
|
||||
cb func(channel *channeldb.DirectedChannel) error) error
|
||||
cb func(channel *graphdb.DirectedChannel) error) error
|
||||
|
||||
// FetchNodeFeatures returns the features of the given node.
|
||||
FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -338,11 +338,11 @@ var _ GraphSessionFactory = (*mockGraphSessionFactory)(nil)
|
||||
var _ Graph = (*mockGraphSessionFactory)(nil)
|
||||
|
||||
type mockGraphSessionFactoryChanDB struct {
|
||||
graph *channeldb.ChannelGraph
|
||||
graph *graphdb.ChannelGraph
|
||||
}
|
||||
|
||||
func newMockGraphSessionFactoryFromChanDB(
|
||||
graph *channeldb.ChannelGraph) *mockGraphSessionFactoryChanDB {
|
||||
graph *graphdb.ChannelGraph) *mockGraphSessionFactoryChanDB {
|
||||
|
||||
return &mockGraphSessionFactoryChanDB{
|
||||
graph: graph,
|
||||
@@ -368,11 +368,11 @@ func (g *mockGraphSessionFactoryChanDB) NewGraphSession() (Graph, func() error,
|
||||
var _ GraphSessionFactory = (*mockGraphSessionFactoryChanDB)(nil)
|
||||
|
||||
type mockGraphSessionChanDB struct {
|
||||
graph *channeldb.ChannelGraph
|
||||
graph *graphdb.ChannelGraph
|
||||
tx kvdb.RTx
|
||||
}
|
||||
|
||||
func newMockGraphSessionChanDB(graph *channeldb.ChannelGraph) Graph {
|
||||
func newMockGraphSessionChanDB(graph *graphdb.ChannelGraph) Graph {
|
||||
return &mockGraphSessionChanDB{
|
||||
graph: graph,
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func (g *mockGraphSessionChanDB) close() error {
|
||||
}
|
||||
|
||||
func (g *mockGraphSessionChanDB) ForEachNodeChannel(nodePub route.Vertex,
|
||||
cb func(channel *channeldb.DirectedChannel) error) error {
|
||||
cb func(channel *graphdb.DirectedChannel) error) error {
|
||||
|
||||
return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -166,12 +166,12 @@ func (m *mockGraph) addChannel(id uint64, node1id, node2id byte,
|
||||
//
|
||||
// NOTE: Part of the Graph interface.
|
||||
func (m *mockGraph) ForEachNodeChannel(nodePub route.Vertex,
|
||||
cb func(channel *channeldb.DirectedChannel) error) error {
|
||||
cb func(channel *graphdb.DirectedChannel) error) error {
|
||||
|
||||
// Look up the mock node.
|
||||
node, ok := m.nodes[nodePub]
|
||||
if !ok {
|
||||
return channeldb.ErrGraphNodeNotFound
|
||||
return graphdb.ErrGraphNodeNotFound
|
||||
}
|
||||
|
||||
// Iterate over all of its channels.
|
||||
@@ -188,7 +188,7 @@ func (m *mockGraph) ForEachNodeChannel(nodePub route.Vertex,
|
||||
|
||||
// Call the per channel callback.
|
||||
err := cb(
|
||||
&channeldb.DirectedChannel{
|
||||
&graphdb.DirectedChannel{
|
||||
ChannelID: channel.id,
|
||||
IsNode1: nodePub == node1,
|
||||
OtherNode: peer,
|
||||
|
||||
+3
-3
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/feature"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -496,7 +496,7 @@ func getOutgoingBalance(node route.Vertex, outgoingChans map[uint64]struct{},
|
||||
g Graph) (lnwire.MilliSatoshi, lnwire.MilliSatoshi, error) {
|
||||
|
||||
var max, total lnwire.MilliSatoshi
|
||||
cb := func(channel *channeldb.DirectedChannel) error {
|
||||
cb := func(channel *graphdb.DirectedChannel) error {
|
||||
if !channel.OutPolicySet {
|
||||
return nil
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ func processNodeForBlindedPath(g Graph, node route.Vertex,
|
||||
// Now, iterate over the node's channels in search for paths to this
|
||||
// node that can be used for blinded paths
|
||||
err = g.ForEachNodeChannel(node,
|
||||
func(channel *channeldb.DirectedChannel) error {
|
||||
func(channel *graphdb.DirectedChannel) error {
|
||||
// Keep track of how many incoming channels this node
|
||||
// has. We only use a node as an introduction node if it
|
||||
// has channels other than the one that lead us to it.
|
||||
|
||||
+14
-13
@@ -23,6 +23,7 @@ import (
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
switchhop "github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
@@ -155,7 +156,7 @@ type testChan struct {
|
||||
|
||||
// makeTestGraph creates a new instance of a channeldb.ChannelGraph for testing
|
||||
// purposes.
|
||||
func makeTestGraph(t *testing.T, useCache bool) (*channeldb.ChannelGraph,
|
||||
func makeTestGraph(t *testing.T, useCache bool) (*graphdb.ChannelGraph,
|
||||
kvdb.Backend, error) {
|
||||
|
||||
// Create channelgraph for the first time.
|
||||
@@ -167,7 +168,7 @@ func makeTestGraph(t *testing.T, useCache bool) (*channeldb.ChannelGraph,
|
||||
t.Cleanup(backendCleanup)
|
||||
|
||||
opts := channeldb.DefaultOptions()
|
||||
graph, err := channeldb.NewChannelGraph(
|
||||
graph, err := graphdb.NewChannelGraph(
|
||||
backend, opts.RejectCacheSize, opts.ChannelCacheSize,
|
||||
opts.BatchCommitInterval, opts.PreAllocCacheNumNodes,
|
||||
useCache, false,
|
||||
@@ -217,7 +218,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
|
||||
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
|
||||
var source *channeldb.LightningNode
|
||||
var source *graphdb.LightningNode
|
||||
|
||||
// First we insert all the nodes within the graph as vertexes.
|
||||
for _, node := range g.Nodes {
|
||||
@@ -226,7 +227,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dbNode := &channeldb.LightningNode{
|
||||
dbNode := &graphdb.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
@@ -357,7 +358,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
}
|
||||
|
||||
err = graph.AddChannelEdge(&edgeInfo)
|
||||
if err != nil && err != channeldb.ErrEdgeAlreadyExist {
|
||||
if err != nil && err != graphdb.ErrEdgeAlreadyExist {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -477,7 +478,7 @@ type testChannel struct {
|
||||
}
|
||||
|
||||
type testGraphInstance struct {
|
||||
graph *channeldb.ChannelGraph
|
||||
graph *graphdb.ChannelGraph
|
||||
graphBackend kvdb.Backend
|
||||
|
||||
// aliasMap is a map from a node's alias to its public key. This type is
|
||||
@@ -539,7 +540,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
|
||||
nodeIndex := byte(0)
|
||||
addNodeWithAlias := func(alias string, features *lnwire.FeatureVector) (
|
||||
*channeldb.LightningNode, error) {
|
||||
*graphdb.LightningNode, error) {
|
||||
|
||||
keyBytes := []byte{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -554,7 +555,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
features = lnwire.EmptyFeatureVector()
|
||||
}
|
||||
|
||||
dbNode := &channeldb.LightningNode{
|
||||
dbNode := &graphdb.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
@@ -665,7 +666,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
}
|
||||
|
||||
err = graph.AddChannelEdge(&edgeInfo)
|
||||
if err != nil && err != channeldb.ErrEdgeAlreadyExist {
|
||||
if err != nil && err != graphdb.ErrEdgeAlreadyExist {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1210,7 +1211,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
|
||||
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
|
||||
require.NoError(t, err, "unable to parse public key from bytes")
|
||||
|
||||
doge := &channeldb.LightningNode{}
|
||||
doge := &graphdb.LightningNode{}
|
||||
doge.AddPubKey(dogePubKey)
|
||||
doge.Alias = "doge"
|
||||
copy(doge.PubKeyBytes[:], dogePubKeyBytes)
|
||||
@@ -3026,7 +3027,7 @@ func runInboundFees(t *testing.T, useCache bool) {
|
||||
|
||||
type pathFindingTestContext struct {
|
||||
t *testing.T
|
||||
graph *channeldb.ChannelGraph
|
||||
graph *graphdb.ChannelGraph
|
||||
restrictParams RestrictParams
|
||||
bandwidthHints bandwidthHints
|
||||
pathFindingConfig PathFindingConfig
|
||||
@@ -3108,7 +3109,7 @@ func (c *pathFindingTestContext) assertPath(path []*unifiedEdge,
|
||||
|
||||
// dbFindPath calls findPath after getting a db transaction from the database
|
||||
// graph.
|
||||
func dbFindPath(graph *channeldb.ChannelGraph,
|
||||
func dbFindPath(graph *graphdb.ChannelGraph,
|
||||
additionalEdges map[route.Vertex][]AdditionalEdge,
|
||||
bandwidthHints bandwidthHints,
|
||||
r *RestrictParams, cfg *PathFindingConfig,
|
||||
@@ -3148,7 +3149,7 @@ func dbFindPath(graph *channeldb.ChannelGraph,
|
||||
|
||||
// dbFindBlindedPaths calls findBlindedPaths after getting a db transaction from
|
||||
// the database graph.
|
||||
func dbFindBlindedPaths(graph *channeldb.ChannelGraph,
|
||||
func dbFindBlindedPaths(graph *graphdb.ChannelGraph,
|
||||
restrictions *blindedPathRestrictions) ([][]blindedHop, error) {
|
||||
|
||||
sourceNode, err := graph.SourceNode()
|
||||
|
||||
@@ -2,8 +2,8 @@ package routing
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
@@ -24,7 +24,7 @@ type SessionSource struct {
|
||||
GraphSessionFactory GraphSessionFactory
|
||||
|
||||
// SourceNode is the graph's source node.
|
||||
SourceNode *channeldb.LightningNode
|
||||
SourceNode *graphdb.LightningNode
|
||||
|
||||
// GetLink is a method that allows querying the lower link layer
|
||||
// to determine the up to date available bandwidth at a prospective link
|
||||
@@ -101,7 +101,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
|
||||
// we'll need to look at the next hint's start node. If
|
||||
// we've reached the end of the hints list, we can
|
||||
// assume we've reached the destination.
|
||||
endNode := &channeldb.LightningNode{}
|
||||
endNode := &graphdb.LightningNode{}
|
||||
if i != len(routeHint)-1 {
|
||||
endNode.AddPubKey(routeHint[i+1].NodeID)
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -89,7 +89,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
|
||||
|
||||
// Create a minimal test node using the private key priv1.
|
||||
pub := priv1.PubKey().SerializeCompressed()
|
||||
testNode := &channeldb.LightningNode{}
|
||||
testNode := &graphdb.LightningNode{}
|
||||
copy(testNode.PubKeyBytes[:], pub)
|
||||
|
||||
nodeID, err := testNode.PubKey()
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/graph"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@@ -68,7 +69,7 @@ type testCtx struct {
|
||||
|
||||
graphBuilder *mockGraphBuilder
|
||||
|
||||
graph *channeldb.ChannelGraph
|
||||
graph *graphdb.ChannelGraph
|
||||
|
||||
aliases map[string]route.Vertex
|
||||
|
||||
@@ -191,7 +192,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
||||
return ctx
|
||||
}
|
||||
|
||||
func createTestNode() (*channeldb.LightningNode, error) {
|
||||
func createTestNode() (*graphdb.LightningNode, error) {
|
||||
updateTime := rand.Int63()
|
||||
|
||||
priv, err := btcec.NewPrivateKey()
|
||||
@@ -200,7 +201,7 @@ func createTestNode() (*channeldb.LightningNode, error) {
|
||||
}
|
||||
|
||||
pub := priv.PubKey().SerializeCompressed()
|
||||
n := &channeldb.LightningNode{
|
||||
n := &graphdb.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(updateTime, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -2898,7 +2899,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
// Now check that we can update the node info for the partial node
|
||||
// without messing up the channel graph.
|
||||
n1 := &channeldb.LightningNode{
|
||||
n1 := &graphdb.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(123, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -2911,7 +2912,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
require.NoError(t, ctx.graph.AddLightningNode(n1))
|
||||
|
||||
n2 := &channeldb.LightningNode{
|
||||
n2 := &graphdb.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(123, 0),
|
||||
Addresses: testAddrs,
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -95,7 +95,7 @@ func (u *nodeEdgeUnifier) addPolicy(fromNode route.Vertex,
|
||||
// addGraphPolicies adds all policies that are known for the toNode in the
|
||||
// graph.
|
||||
func (u *nodeEdgeUnifier) addGraphPolicies(g Graph) error {
|
||||
cb := func(channel *channeldb.DirectedChannel) error {
|
||||
cb := func(channel *graphdb.DirectedChannel) error {
|
||||
// If there is no edge policy for this candidate node, skip.
|
||||
// Note that we are searching backwards so this node would have
|
||||
// come prior to the pivot node in the route.
|
||||
|
||||
Reference in new issue
Block a user