graph/db: remove GraphCacheNode interface
With the previous commit, the AddNode method was removed and since that was the only method making use of the ForEachChannel on the GraphCacheNode interface, we can remove that method. Since the only two methods left just expose the node's pub key and features, it really is not required anymore and so the entire thing can be removed along with the implementation of it.
This commit is contained in:
5 files changed
+77
-191
No files matched your search
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -25,39 +24,6 @@ var (
|
||||
pubKey2, _ = route.NewVertexFromBytes(pubKey2Bytes)
|
||||
)
|
||||
|
||||
type node struct {
|
||||
pubKey route.Vertex
|
||||
features *lnwire.FeatureVector
|
||||
|
||||
edgeInfos []*models.ChannelEdgeInfo
|
||||
outPolicies []*models.ChannelEdgePolicy
|
||||
inPolicies []*models.ChannelEdgePolicy
|
||||
}
|
||||
|
||||
func (n *node) PubKey() route.Vertex {
|
||||
return n.pubKey
|
||||
}
|
||||
func (n *node) Features() *lnwire.FeatureVector {
|
||||
return n.features
|
||||
}
|
||||
|
||||
func (n *node) ForEachChannel(tx kvdb.RTx,
|
||||
cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error) error {
|
||||
|
||||
for idx := range n.edgeInfos {
|
||||
err := cb(
|
||||
tx, n.edgeInfos[idx], n.outPolicies[idx],
|
||||
n.inPolicies[idx],
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TestGraphCacheAddNode tests that a channel going from node A to node B can be
|
||||
// cached correctly, independent of the direction we add the channel as.
|
||||
func TestGraphCacheAddNode(t *testing.T) {
|
||||
@@ -85,12 +51,8 @@ func TestGraphCacheAddNode(t *testing.T) {
|
||||
ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagB),
|
||||
ToNode: nodeA,
|
||||
}
|
||||
node := &node{
|
||||
pubKey: nodeA,
|
||||
features: lnwire.EmptyFeatureVector(),
|
||||
}
|
||||
cache := NewGraphCache(10)
|
||||
cache.AddNodeFeatures(node)
|
||||
cache.AddNodeFeatures(nodeA, lnwire.EmptyFeatureVector())
|
||||
cache.AddChannel(&models.ChannelEdgeInfo{
|
||||
ChannelID: 1000,
|
||||
// Those are direction independent!
|
||||
|
||||
Reference in new issue
Block a user