multi: move LightningNode struct to models package
This commit is contained in:
20 files changed
+252
-246
No files matched your search
+5
-5
@@ -1165,7 +1165,7 @@ func (b *Builder) processUpdate(msg interface{},
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *graphdb.LightningNode:
|
||||
case *models.LightningNode:
|
||||
// Before we add the node to the database, we'll check to see
|
||||
// if the announcement is "fresh" or not. If it isn't, then
|
||||
// we'll return an error.
|
||||
@@ -1517,7 +1517,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
|
||||
// be ignored.
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) AddNode(node *graphdb.LightningNode,
|
||||
func (b *Builder) AddNode(node *models.LightningNode,
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
rMsg := &routingMsg{
|
||||
@@ -1624,7 +1624,7 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) (
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) FetchLightningNode(
|
||||
node route.Vertex) (*graphdb.LightningNode, error) {
|
||||
node route.Vertex) (*models.LightningNode, error) {
|
||||
|
||||
return b.cfg.Graph.FetchLightningNode(node)
|
||||
}
|
||||
@@ -1633,10 +1633,10 @@ func (b *Builder) FetchLightningNode(
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) ForEachNode(
|
||||
cb func(*graphdb.LightningNode) error) error {
|
||||
cb func(*models.LightningNode) error) error {
|
||||
|
||||
return b.cfg.Graph.ForEachNode(
|
||||
func(_ kvdb.RTx, n *graphdb.LightningNode) error {
|
||||
func(_ kvdb.RTx, n *models.LightningNode) error {
|
||||
return cb(n)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
|
||||
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
|
||||
|
||||
pub := priv1.PubKey()
|
||||
node := &graphdb.LightningNode{
|
||||
node := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(123, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -1038,7 +1038,7 @@ func TestIsStaleNode(t *testing.T) {
|
||||
|
||||
// With the node stub in the database, we'll add the fully node
|
||||
// announcement to the database.
|
||||
n1 := &graphdb.LightningNode{
|
||||
n1 := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: updateTimeStamp,
|
||||
Addresses: testAddrs,
|
||||
@@ -1453,7 +1453,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 *graphdb.LightningNode
|
||||
var source *models.LightningNode
|
||||
|
||||
// First we insert all the nodes within the graph as vertexes.
|
||||
for _, node := range g.Nodes {
|
||||
@@ -1462,7 +1462,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dbNode := &graphdb.LightningNode{
|
||||
dbNode := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
@@ -1832,7 +1832,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
|
||||
nodeIndex := byte(0)
|
||||
addNodeWithAlias := func(alias string, features *lnwire.FeatureVector) (
|
||||
*graphdb.LightningNode, error) {
|
||||
*models.LightningNode, error) {
|
||||
|
||||
keyBytes := []byte{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -1847,7 +1847,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
features = lnwire.EmptyFeatureVector()
|
||||
}
|
||||
|
||||
dbNode := &graphdb.LightningNode{
|
||||
dbNode := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
|
||||
+37
-160
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
@@ -16,7 +15,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
@@ -602,7 +600,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
|
||||
// We'll iterate over each node, then the set of channels for each
|
||||
// node, and construct a similar callback functiopn signature as the
|
||||
// main funcotin expects.
|
||||
return c.ForEachNode(func(tx kvdb.RTx, node *LightningNode) error {
|
||||
return c.ForEachNode(func(tx kvdb.RTx, node *models.LightningNode) error {
|
||||
channels := make(map[uint64]*DirectedChannel)
|
||||
|
||||
err := c.ForEachNodeChannelTx(tx, node.PubKeyBytes,
|
||||
@@ -710,7 +708,7 @@ func (c *ChannelGraph) DisabledChannelIDs() ([]uint64, error) {
|
||||
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
|
||||
// traversal when graph gets mega
|
||||
func (c *ChannelGraph) ForEachNode(
|
||||
cb func(kvdb.RTx, *LightningNode) error) error {
|
||||
cb func(kvdb.RTx, *models.LightningNode) error) error {
|
||||
|
||||
traversal := func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
@@ -787,8 +785,8 @@ func (c *ChannelGraph) ForEachNodeCacheable(cb func(kvdb.RTx,
|
||||
// as the center node within a star-graph. This method may be used to kick off
|
||||
// a path finding algorithm in order to explore the reachability of another
|
||||
// node based off the source node.
|
||||
func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
|
||||
var source *LightningNode
|
||||
func (c *ChannelGraph) SourceNode() (*models.LightningNode, error) {
|
||||
var source *models.LightningNode
|
||||
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
@@ -818,7 +816,7 @@ func (c *ChannelGraph) SourceNode() (*LightningNode, error) {
|
||||
// of the graph. The source node is treated as the center node within a
|
||||
// star-graph. This method may be used to kick off a path finding algorithm in
|
||||
// order to explore the reachability of another node based off the source node.
|
||||
func (c *ChannelGraph) sourceNode(nodes kvdb.RBucket) (*LightningNode, error) {
|
||||
func (c *ChannelGraph) sourceNode(nodes kvdb.RBucket) (*models.LightningNode, error) {
|
||||
selfPub := nodes.Get(sourceKey)
|
||||
if selfPub == nil {
|
||||
return nil, ErrSourceNodeNotSet
|
||||
@@ -837,7 +835,7 @@ func (c *ChannelGraph) sourceNode(nodes kvdb.RBucket) (*LightningNode, error) {
|
||||
// SetSourceNode sets the source node within the graph database. The source
|
||||
// node is to be used as the center of a star-graph within path finding
|
||||
// algorithms.
|
||||
func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
|
||||
func (c *ChannelGraph) SetSourceNode(node *models.LightningNode) error {
|
||||
nodePubBytes := node.PubKeyBytes[:]
|
||||
|
||||
return kvdb.Update(c.db, func(tx kvdb.RwTx) error {
|
||||
@@ -868,7 +866,7 @@ func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
|
||||
// channel update.
|
||||
//
|
||||
// TODO(roasbeef): also need sig of announcement
|
||||
func (c *ChannelGraph) AddLightningNode(node *LightningNode,
|
||||
func (c *ChannelGraph) AddLightningNode(node *models.LightningNode,
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
r := &batch.Request{
|
||||
@@ -894,7 +892,7 @@ func (c *ChannelGraph) AddLightningNode(node *LightningNode,
|
||||
return c.nodeScheduler.Execute(r)
|
||||
}
|
||||
|
||||
func addLightningNode(tx kvdb.RwTx, node *LightningNode) error {
|
||||
func addLightningNode(tx kvdb.RwTx, node *models.LightningNode) error {
|
||||
nodes, err := tx.CreateTopLevelBucket(nodeBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1107,7 +1105,7 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx,
|
||||
_, node1Err := fetchLightningNode(nodes, edge.NodeKey1Bytes[:])
|
||||
switch {
|
||||
case node1Err == ErrGraphNodeNotFound:
|
||||
node1Shell := LightningNode{
|
||||
node1Shell := models.LightningNode{
|
||||
PubKeyBytes: edge.NodeKey1Bytes,
|
||||
HaveNodeAnnouncement: false,
|
||||
}
|
||||
@@ -1123,7 +1121,7 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx,
|
||||
_, node2Err := fetchLightningNode(nodes, edge.NodeKey2Bytes[:])
|
||||
switch {
|
||||
case node2Err == ErrGraphNodeNotFound:
|
||||
node2Shell := LightningNode{
|
||||
node2Shell := models.LightningNode{
|
||||
PubKeyBytes: edge.NodeKey2Bytes,
|
||||
HaveNodeAnnouncement: false,
|
||||
}
|
||||
@@ -1922,11 +1920,11 @@ type ChannelEdge struct {
|
||||
|
||||
// Node1 is "node 1" in the channel. This is the node that would have
|
||||
// produced Policy1 if it exists.
|
||||
Node1 *LightningNode
|
||||
Node1 *models.LightningNode
|
||||
|
||||
// Node2 is "node 2" in the channel. This is the node that would have
|
||||
// produced Policy2 if it exists.
|
||||
Node2 *LightningNode
|
||||
Node2 *models.LightningNode
|
||||
}
|
||||
|
||||
// ChanUpdatesInHorizon returns all the known channel edges which have at least
|
||||
@@ -2082,9 +2080,9 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime,
|
||||
// nodes to quickly determine if they have the same set of up to date node
|
||||
// announcements.
|
||||
func (c *ChannelGraph) NodeUpdatesInHorizon(startTime,
|
||||
endTime time.Time) ([]LightningNode, error) {
|
||||
endTime time.Time) ([]models.LightningNode, error) {
|
||||
|
||||
var nodesInHorizon []LightningNode
|
||||
var nodesInHorizon []models.LightningNode
|
||||
|
||||
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||
nodes := tx.ReadBucket(nodeBucket)
|
||||
@@ -2880,127 +2878,6 @@ func updateEdgePolicy(tx kvdb.RwTx, edge *models.ChannelEdgePolicy,
|
||||
return isUpdate1, nil
|
||||
}
|
||||
|
||||
// LightningNode represents an individual vertex/node within the channel graph.
|
||||
// A node is connected to other nodes by one or more channel edges emanating
|
||||
// from it. As the graph is directed, a node will also have an incoming edge
|
||||
// attached to it for each outgoing edge.
|
||||
type LightningNode struct {
|
||||
// PubKeyBytes is the raw bytes of the public key of the target node.
|
||||
PubKeyBytes [33]byte
|
||||
pubKey *btcec.PublicKey
|
||||
|
||||
// HaveNodeAnnouncement indicates whether we received a node
|
||||
// announcement for this particular node. If true, the remaining fields
|
||||
// will be set, if false only the PubKey is known for this node.
|
||||
HaveNodeAnnouncement bool
|
||||
|
||||
// LastUpdate is the last time the vertex information for this node has
|
||||
// been updated.
|
||||
LastUpdate time.Time
|
||||
|
||||
// Address is the TCP address this node is reachable over.
|
||||
Addresses []net.Addr
|
||||
|
||||
// Color is the selected color for the node.
|
||||
Color color.RGBA
|
||||
|
||||
// Alias is a nick-name for the node. The alias can be used to confirm
|
||||
// a node's identity or to serve as a short ID for an address book.
|
||||
Alias string
|
||||
|
||||
// AuthSigBytes is the raw signature under the advertised public key
|
||||
// which serves to authenticate the attributes announced by this node.
|
||||
AuthSigBytes []byte
|
||||
|
||||
// Features is the list of protocol features supported by this node.
|
||||
Features *lnwire.FeatureVector
|
||||
|
||||
// ExtraOpaqueData is the set of data that was appended to this
|
||||
// message, some of which we may not actually know how to iterate or
|
||||
// parse. By holding onto this data, we ensure that we're able to
|
||||
// properly validate the set of signatures that cover these new fields,
|
||||
// and ensure we're able to make upgrades to the network in a forwards
|
||||
// compatible manner.
|
||||
ExtraOpaqueData []byte
|
||||
|
||||
// TODO(roasbeef): discovery will need storage to keep it's last IP
|
||||
// address and re-announce if interface changes?
|
||||
|
||||
// TODO(roasbeef): add update method and fetch?
|
||||
}
|
||||
|
||||
// PubKey is the node's long-term identity public key. This key will be used to
|
||||
// authenticated any advertisements/updates sent by the node.
|
||||
//
|
||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||
// to fully deserialize the pubkey if absolutely necessary.
|
||||
func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
|
||||
if l.pubKey != nil {
|
||||
return l.pubKey, nil
|
||||
}
|
||||
|
||||
key, err := btcec.ParsePubKey(l.PubKeyBytes[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l.pubKey = key
|
||||
|
||||
return key, nil
|
||||
}
|
||||
|
||||
// AuthSig is a signature under the advertised public key which serves to
|
||||
// authenticate the attributes announced by this node.
|
||||
//
|
||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||
// to fully deserialize the signature if absolutely necessary.
|
||||
func (l *LightningNode) AuthSig() (*ecdsa.Signature, error) {
|
||||
return ecdsa.ParseSignature(l.AuthSigBytes)
|
||||
}
|
||||
|
||||
// AddPubKey is a setter-link method that can be used to swap out the public
|
||||
// key for a node.
|
||||
func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
|
||||
l.pubKey = key
|
||||
copy(l.PubKeyBytes[:], key.SerializeCompressed())
|
||||
}
|
||||
|
||||
// NodeAnnouncement retrieves the latest node announcement of the node.
|
||||
func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
||||
error) {
|
||||
|
||||
if !l.HaveNodeAnnouncement {
|
||||
return nil, fmt.Errorf("node does not have node announcement")
|
||||
}
|
||||
|
||||
alias, err := lnwire.NewNodeAlias(l.Alias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeAnn := &lnwire.NodeAnnouncement{
|
||||
Features: l.Features.RawFeatureVector,
|
||||
NodeID: l.PubKeyBytes,
|
||||
RGBColor: l.Color,
|
||||
Alias: alias,
|
||||
Addresses: l.Addresses,
|
||||
Timestamp: uint32(l.LastUpdate.Unix()),
|
||||
ExtraOpaqueData: l.ExtraOpaqueData,
|
||||
}
|
||||
|
||||
if !signed {
|
||||
return nodeAnn, nil
|
||||
}
|
||||
|
||||
sig, err := lnwire.NewSigFromECDSARawSignature(l.AuthSigBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeAnn.Signature = sig
|
||||
|
||||
return nodeAnn, nil
|
||||
}
|
||||
|
||||
// isPublic determines whether the node is seen as public within the graph from
|
||||
// the source node's point of view. An existing database transaction can also be
|
||||
// specified.
|
||||
@@ -3050,7 +2927,7 @@ func (c *ChannelGraph) isPublic(tx kvdb.RTx, nodePub route.Vertex,
|
||||
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
||||
// If none is provided, then a new one will be created.
|
||||
func (c *ChannelGraph) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
||||
*LightningNode, error) {
|
||||
*models.LightningNode, error) {
|
||||
|
||||
return c.fetchLightningNode(tx, nodePub)
|
||||
}
|
||||
@@ -3058,7 +2935,7 @@ func (c *ChannelGraph) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
||||
// FetchLightningNode attempts to look up a target node by its identity public
|
||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||
// returned.
|
||||
func (c *ChannelGraph) FetchLightningNode(nodePub route.Vertex) (*LightningNode,
|
||||
func (c *ChannelGraph) FetchLightningNode(nodePub route.Vertex) (*models.LightningNode,
|
||||
error) {
|
||||
|
||||
return c.fetchLightningNode(nil, nodePub)
|
||||
@@ -3069,9 +2946,9 @@ func (c *ChannelGraph) FetchLightningNode(nodePub route.Vertex) (*LightningNode,
|
||||
// returned. An optional transaction may be provided. If none is provided, then
|
||||
// a new one will be created.
|
||||
func (c *ChannelGraph) fetchLightningNode(tx kvdb.RTx,
|
||||
nodePub route.Vertex) (*LightningNode, error) {
|
||||
nodePub route.Vertex) (*models.LightningNode, error) {
|
||||
|
||||
var node *LightningNode
|
||||
var node *models.LightningNode
|
||||
fetch := func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
@@ -3339,7 +3216,7 @@ func (c *ChannelGraph) ForEachNodeChannelTx(tx kvdb.RTx,
|
||||
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
||||
// end of the channel.
|
||||
func (c *ChannelGraph) FetchOtherNode(tx kvdb.RTx,
|
||||
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (*LightningNode,
|
||||
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (*models.LightningNode,
|
||||
error) {
|
||||
|
||||
// Ensure that the node passed in is actually a member of the channel.
|
||||
@@ -3353,7 +3230,7 @@ func (c *ChannelGraph) FetchOtherNode(tx kvdb.RTx,
|
||||
return nil, fmt.Errorf("node not participating in this channel")
|
||||
}
|
||||
|
||||
var targetNode *LightningNode
|
||||
var targetNode *models.LightningNode
|
||||
fetchNodeFunc := func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
@@ -3976,7 +3853,7 @@ func (c *ChannelGraph) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
||||
}
|
||||
|
||||
func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // nolint:dupl
|
||||
updateIndex kvdb.RwBucket, node *LightningNode) error {
|
||||
updateIndex kvdb.RwBucket, node *models.LightningNode) error {
|
||||
|
||||
var (
|
||||
scratch [16]byte
|
||||
@@ -4105,11 +3982,11 @@ func putLightningNode(nodeBucket kvdb.RwBucket, aliasBucket kvdb.RwBucket, // no
|
||||
}
|
||||
|
||||
func fetchLightningNode(nodeBucket kvdb.RBucket,
|
||||
nodePub []byte) (LightningNode, error) {
|
||||
nodePub []byte) (models.LightningNode, error) {
|
||||
|
||||
nodeBytes := nodeBucket.Get(nodePub)
|
||||
if nodeBytes == nil {
|
||||
return LightningNode{}, ErrGraphNodeNotFound
|
||||
return models.LightningNode{}, ErrGraphNodeNotFound
|
||||
}
|
||||
|
||||
nodeReader := bytes.NewReader(nodeBytes)
|
||||
@@ -4172,9 +4049,9 @@ func deserializeLightningNodeCacheable(r io.Reader) (*graphCacheNode, error) {
|
||||
return node, nil
|
||||
}
|
||||
|
||||
func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
||||
var (
|
||||
node LightningNode
|
||||
node models.LightningNode
|
||||
scratch [8]byte
|
||||
err error
|
||||
)
|
||||
@@ -4184,18 +4061,18 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
node.Features = lnwire.EmptyFeatureVector()
|
||||
|
||||
if _, err := r.Read(scratch[:]); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
unix := int64(byteOrder.Uint64(scratch[:]))
|
||||
node.LastUpdate = time.Unix(unix, 0)
|
||||
|
||||
if _, err := io.ReadFull(r, node.PubKeyBytes[:]); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
if _, err := r.Read(scratch[:2]); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
hasNodeAnn := byteOrder.Uint16(scratch[:2])
|
||||
@@ -4214,27 +4091,27 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
// We did get a node announcement for this node, so we'll have the rest
|
||||
// of the data available.
|
||||
if err := binary.Read(r, byteOrder, &node.Color.R); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
if err := binary.Read(r, byteOrder, &node.Color.G); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
if err := binary.Read(r, byteOrder, &node.Color.B); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
node.Alias, err = wire.ReadVarString(r, 0)
|
||||
if err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
err = node.Features.Decode(r)
|
||||
if err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
if _, err := r.Read(scratch[:2]); err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
numAddresses := int(byteOrder.Uint16(scratch[:2]))
|
||||
|
||||
@@ -4242,7 +4119,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
for i := 0; i < numAddresses; i++ {
|
||||
address, err := DeserializeAddr(r)
|
||||
if err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
addresses = append(addresses, address)
|
||||
}
|
||||
@@ -4250,7 +4127,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
|
||||
node.AuthSigBytes, err = wire.ReadVarBytes(r, 0, 80, "sig")
|
||||
if err != nil {
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
// We'll try and see if there are any opaque bytes left, if not, then
|
||||
@@ -4262,7 +4139,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) {
|
||||
case err == io.ErrUnexpectedEOF:
|
||||
case err == io.EOF:
|
||||
case err != nil:
|
||||
return LightningNode{}, err
|
||||
return models.LightningNode{}, err
|
||||
}
|
||||
|
||||
return node, nil
|
||||
|
||||
+24
-24
@@ -65,11 +65,11 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func createLightningNode(db kvdb.Backend, priv *btcec.PrivateKey) (*LightningNode, error) {
|
||||
func createLightningNode(db kvdb.Backend, priv *btcec.PrivateKey) (*models.LightningNode, error) {
|
||||
updateTime := prand.Int63()
|
||||
|
||||
pub := priv.PubKey().SerializeCompressed()
|
||||
n := &LightningNode{
|
||||
n := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: time.Unix(updateTime, 0),
|
||||
@@ -83,7 +83,7 @@ func createLightningNode(db kvdb.Backend, priv *btcec.PrivateKey) (*LightningNod
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func createTestVertex(db kvdb.Backend) (*LightningNode, error) {
|
||||
func createTestVertex(db kvdb.Backend) (*models.LightningNode, error) {
|
||||
priv, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -100,7 +100,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
|
||||
// We'd like to test basic insertion/deletion for vertexes from the
|
||||
// graph, so we'll create a test vertex to start with.
|
||||
node := &LightningNode{
|
||||
node := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: time.Unix(1232342, 0),
|
||||
@@ -160,7 +160,7 @@ func TestPartialNode(t *testing.T) {
|
||||
|
||||
// We want to be able to insert nodes into the graph that only has the
|
||||
// PubKey set.
|
||||
node := &LightningNode{
|
||||
node := &models.LightningNode{
|
||||
HaveNodeAnnouncement: false,
|
||||
PubKeyBytes: testPub,
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func TestPartialNode(t *testing.T) {
|
||||
|
||||
// The two nodes should match exactly! (with default values for
|
||||
// LastUpdate and db set to satisfy compareNodes())
|
||||
node = &LightningNode{
|
||||
node = &models.LightningNode{
|
||||
HaveNodeAnnouncement: false,
|
||||
LastUpdate: time.Unix(0, 0),
|
||||
PubKeyBytes: testPub,
|
||||
@@ -366,7 +366,7 @@ func TestEdgeInsertionDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
|
||||
node1, node2 *LightningNode) (models.ChannelEdgeInfo,
|
||||
node1, node2 *models.LightningNode) (models.ChannelEdgeInfo,
|
||||
lnwire.ShortChannelID) {
|
||||
|
||||
shortChanID := lnwire.ShortChannelID{
|
||||
@@ -598,7 +598,7 @@ func assertEdgeInfoEqual(t *testing.T, e1 *models.ChannelEdgeInfo,
|
||||
}
|
||||
}
|
||||
|
||||
func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) (
|
||||
func createChannelEdge(db kvdb.Backend, node1, node2 *models.LightningNode) (
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) {
|
||||
|
||||
@@ -770,7 +770,7 @@ func TestEdgeInfoUpdates(t *testing.T) {
|
||||
assertEdgeInfoEqual(t, dbEdgeInfo, edgeInfo)
|
||||
}
|
||||
|
||||
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *LightningNode,
|
||||
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.LightningNode,
|
||||
expectedFeatures *lnwire.FeatureVector) {
|
||||
|
||||
// Let's check the internal view first.
|
||||
@@ -1089,7 +1089,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
||||
// Create a map of all nodes with the iteration we know works (because
|
||||
// it is tested in another test).
|
||||
nodeMap := make(map[route.Vertex]struct{})
|
||||
err = graph.ForEachNode(func(tx kvdb.RTx, n *LightningNode) error {
|
||||
err = graph.ForEachNode(func(tx kvdb.RTx, n *models.LightningNode) error {
|
||||
nodeMap[n.PubKeyBytes] = struct{}{}
|
||||
|
||||
return nil
|
||||
@@ -1192,9 +1192,9 @@ func TestGraphCacheTraversal(t *testing.T) {
|
||||
}
|
||||
|
||||
func fillTestGraph(t require.TestingT, graph *ChannelGraph, numNodes,
|
||||
numChannels int) (map[uint64]struct{}, []*LightningNode) {
|
||||
numChannels int) (map[uint64]struct{}, []*models.LightningNode) {
|
||||
|
||||
nodes := make([]*LightningNode, numNodes)
|
||||
nodes := make([]*models.LightningNode, numNodes)
|
||||
nodeIndex := map[string]struct{}{}
|
||||
for i := 0; i < numNodes; i++ {
|
||||
node, err := createTestVertex(graph.db)
|
||||
@@ -1212,7 +1212,7 @@ func fillTestGraph(t require.TestingT, graph *ChannelGraph, numNodes,
|
||||
|
||||
// Iterate over each node as returned by the graph, if all nodes are
|
||||
// reached, then the map created above should be empty.
|
||||
err := graph.ForEachNode(func(_ kvdb.RTx, node *LightningNode) error {
|
||||
err := graph.ForEachNode(func(_ kvdb.RTx, node *models.LightningNode) error {
|
||||
delete(nodeIndex, node.Alias)
|
||||
return nil
|
||||
})
|
||||
@@ -1320,7 +1320,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
||||
|
||||
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
||||
numNodes := 0
|
||||
err := graph.ForEachNode(func(_ kvdb.RTx, _ *LightningNode) error {
|
||||
err := graph.ForEachNode(func(_ kvdb.RTx, _ *models.LightningNode) error {
|
||||
numNodes++
|
||||
return nil
|
||||
})
|
||||
@@ -1391,7 +1391,7 @@ func TestGraphPruning(t *testing.T) {
|
||||
// and enough edges to create a fully connected graph. The graph will
|
||||
// be rather simple, representing a straight line.
|
||||
const numNodes = 5
|
||||
graphNodes := make([]*LightningNode, numNodes)
|
||||
graphNodes := make([]*models.LightningNode, numNodes)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
node, err := createTestVertex(graph.db)
|
||||
if err != nil {
|
||||
@@ -1809,7 +1809,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
||||
// We'll create 10 node announcements, each with an update timestamp 10
|
||||
// seconds after the other.
|
||||
const numNodes = 10
|
||||
nodeAnns := make([]LightningNode, 0, numNodes)
|
||||
nodeAnns := make([]models.LightningNode, 0, numNodes)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
nodeAnn, err := createTestVertex(graph.db)
|
||||
if err != nil {
|
||||
@@ -1835,7 +1835,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
||||
start time.Time
|
||||
end time.Time
|
||||
|
||||
resp []LightningNode
|
||||
resp []models.LightningNode
|
||||
}{
|
||||
// If we query for a time range that's strictly below our set
|
||||
// of updates, then we'll get an empty result back.
|
||||
@@ -2408,7 +2408,7 @@ func TestFilterChannelRange(t *testing.T) {
|
||||
)
|
||||
|
||||
updateTimeSeed := time.Now().Unix()
|
||||
maybeAddPolicy := func(chanID uint64, node *LightningNode,
|
||||
maybeAddPolicy := func(chanID uint64, node *models.LightningNode,
|
||||
node2 bool) time.Time {
|
||||
|
||||
var chanFlags lnwire.ChanUpdateChanFlags
|
||||
@@ -2725,7 +2725,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure that channel is reported with unknown policies.
|
||||
checkPolicies := func(node *LightningNode, expectedIn, expectedOut bool) {
|
||||
checkPolicies := func(node *models.LightningNode, expectedIn, expectedOut bool) {
|
||||
calls := 0
|
||||
err := graph.ForEachNodeChannel(node.PubKeyBytes,
|
||||
func(_ kvdb.RTx, _ *models.ChannelEdgeInfo, outEdge,
|
||||
@@ -3145,7 +3145,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
|
||||
// After creating all of our nodes and edges, we'll add them to each
|
||||
// participant's graph.
|
||||
nodes := []*LightningNode{aliceNode, bobNode, carolNode}
|
||||
nodes := []*models.LightningNode{aliceNode, bobNode, carolNode}
|
||||
edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge}
|
||||
graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph}
|
||||
for _, graph := range graphs {
|
||||
@@ -3163,7 +3163,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
|
||||
// checkNodes is a helper closure that will be used to assert that the
|
||||
// given nodes are seen as public/private within the given graphs.
|
||||
checkNodes := func(nodes []*LightningNode, graphs []*ChannelGraph,
|
||||
checkNodes := func(nodes []*models.LightningNode, graphs []*ChannelGraph,
|
||||
public bool) {
|
||||
|
||||
t.Helper()
|
||||
@@ -3204,7 +3204,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
checkNodes(
|
||||
[]*LightningNode{aliceNode},
|
||||
[]*models.LightningNode{aliceNode},
|
||||
[]*ChannelGraph{bobGraph, carolGraph},
|
||||
false,
|
||||
)
|
||||
@@ -3235,7 +3235,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
// With the modifications above, Bob should now be seen as a private
|
||||
// node from both Alice's and Carol's perspective.
|
||||
checkNodes(
|
||||
[]*LightningNode{bobNode},
|
||||
[]*models.LightningNode{bobNode},
|
||||
[]*ChannelGraph{aliceGraph, carolGraph},
|
||||
false,
|
||||
)
|
||||
@@ -3554,7 +3554,7 @@ func TestGraphZombieIndex(t *testing.T) {
|
||||
// compareNodes is used to compare two LightningNodes while excluding the
|
||||
// Features struct, which cannot be compared as the semantics for reserializing
|
||||
// the featuresMap have not been defined.
|
||||
func compareNodes(a, b *LightningNode) error {
|
||||
func compareNodes(a, b *models.LightningNode) error {
|
||||
if a.LastUpdate != b.LastUpdate {
|
||||
return fmt.Errorf("node LastUpdate doesn't match: expected %v, \n"+
|
||||
"got %v", a.LastUpdate, b.LastUpdate)
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
// LightningNode represents an individual vertex/node within the channel graph.
|
||||
// A node is connected to other nodes by one or more channel edges emanating
|
||||
// from it. As the graph is directed, a node will also have an incoming edge
|
||||
// attached to it for each outgoing edge.
|
||||
type LightningNode struct {
|
||||
// PubKeyBytes is the raw bytes of the public key of the target node.
|
||||
PubKeyBytes [33]byte
|
||||
pubKey *btcec.PublicKey
|
||||
|
||||
// HaveNodeAnnouncement indicates whether we received a node
|
||||
// announcement for this particular node. If true, the remaining fields
|
||||
// will be set, if false only the PubKey is known for this node.
|
||||
HaveNodeAnnouncement bool
|
||||
|
||||
// LastUpdate is the last time the vertex information for this node has
|
||||
// been updated.
|
||||
LastUpdate time.Time
|
||||
|
||||
// Address is the TCP address this node is reachable over.
|
||||
Addresses []net.Addr
|
||||
|
||||
// Color is the selected color for the node.
|
||||
Color color.RGBA
|
||||
|
||||
// Alias is a nick-name for the node. The alias can be used to confirm
|
||||
// a node's identity or to serve as a short ID for an address book.
|
||||
Alias string
|
||||
|
||||
// AuthSigBytes is the raw signature under the advertised public key
|
||||
// which serves to authenticate the attributes announced by this node.
|
||||
AuthSigBytes []byte
|
||||
|
||||
// Features is the list of protocol features supported by this node.
|
||||
Features *lnwire.FeatureVector
|
||||
|
||||
// ExtraOpaqueData is the set of data that was appended to this
|
||||
// message, some of which we may not actually know how to iterate or
|
||||
// parse. By holding onto this data, we ensure that we're able to
|
||||
// properly validate the set of signatures that cover these new fields,
|
||||
// and ensure we're able to make upgrades to the network in a forwards
|
||||
// compatible manner.
|
||||
ExtraOpaqueData []byte
|
||||
|
||||
// TODO(roasbeef): discovery will need storage to keep it's last IP
|
||||
// address and re-announce if interface changes?
|
||||
|
||||
// TODO(roasbeef): add update method and fetch?
|
||||
}
|
||||
|
||||
// PubKey is the node's long-term identity public key. This key will be used to
|
||||
// authenticated any advertisements/updates sent by the node.
|
||||
//
|
||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||
// to fully deserialize the pubkey if absolutely necessary.
|
||||
func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
|
||||
if l.pubKey != nil {
|
||||
return l.pubKey, nil
|
||||
}
|
||||
|
||||
key, err := btcec.ParsePubKey(l.PubKeyBytes[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
l.pubKey = key
|
||||
|
||||
return key, nil
|
||||
}
|
||||
|
||||
// AuthSig is a signature under the advertised public key which serves to
|
||||
// authenticate the attributes announced by this node.
|
||||
//
|
||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||
// to fully deserialize the signature if absolutely necessary.
|
||||
func (l *LightningNode) AuthSig() (*ecdsa.Signature, error) {
|
||||
return ecdsa.ParseSignature(l.AuthSigBytes)
|
||||
}
|
||||
|
||||
// AddPubKey is a setter-link method that can be used to swap out the public
|
||||
// key for a node.
|
||||
func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
|
||||
l.pubKey = key
|
||||
copy(l.PubKeyBytes[:], key.SerializeCompressed())
|
||||
}
|
||||
|
||||
// NodeAnnouncement retrieves the latest node announcement of the node.
|
||||
func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
||||
error) {
|
||||
|
||||
if !l.HaveNodeAnnouncement {
|
||||
return nil, fmt.Errorf("node does not have node announcement")
|
||||
}
|
||||
|
||||
alias, err := lnwire.NewNodeAlias(l.Alias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeAnn := &lnwire.NodeAnnouncement{
|
||||
Features: l.Features.RawFeatureVector,
|
||||
NodeID: l.PubKeyBytes,
|
||||
RGBColor: l.Color,
|
||||
Alias: alias,
|
||||
Addresses: l.Addresses,
|
||||
Timestamp: uint32(l.LastUpdate.Unix()),
|
||||
ExtraOpaqueData: l.ExtraOpaqueData,
|
||||
}
|
||||
|
||||
if !signed {
|
||||
return nodeAnn, nil
|
||||
}
|
||||
|
||||
sig, err := lnwire.NewSigFromECDSARawSignature(l.AuthSigBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodeAnn.Signature = sig
|
||||
|
||||
return nodeAnn, nil
|
||||
}
|
||||
+7
-7
@@ -23,7 +23,7 @@ type ChannelGraphSource interface {
|
||||
// AddNode is used to add information about a node to the router
|
||||
// database. If the node with this pubkey is not present in an existing
|
||||
// channel, it will be ignored.
|
||||
AddNode(node *graphdb.LightningNode,
|
||||
AddNode(node *models.LightningNode,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// AddEdge is used to add edge/channel to the topology of the router,
|
||||
@@ -85,10 +85,10 @@ type ChannelGraphSource interface {
|
||||
// FetchLightningNode attempts to look up a target node by its identity
|
||||
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
||||
// doesn't exist within the graph.
|
||||
FetchLightningNode(route.Vertex) (*graphdb.LightningNode, error)
|
||||
FetchLightningNode(route.Vertex) (*models.LightningNode, error)
|
||||
|
||||
// ForEachNode is used to iterate over every node in the known graph.
|
||||
ForEachNode(func(node *graphdb.LightningNode) error) error
|
||||
ForEachNode(func(node *models.LightningNode) error) error
|
||||
}
|
||||
|
||||
// DB is an interface describing a persisted Lightning Network graph.
|
||||
@@ -129,7 +129,7 @@ type DB interface {
|
||||
// treated as the center node within a star-graph. This method may be
|
||||
// used to kick off a path finding algorithm in order to explore the
|
||||
// reachability of another node based off the source node.
|
||||
SourceNode() (*graphdb.LightningNode, error)
|
||||
SourceNode() (*models.LightningNode, error)
|
||||
|
||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
@@ -200,7 +200,7 @@ type DB interface {
|
||||
// update that node's information. Note that this method is expected to
|
||||
// only be called to update an already present node from a node
|
||||
// announcement, or to insert a node found in a channel update.
|
||||
AddLightningNode(node *graphdb.LightningNode,
|
||||
AddLightningNode(node *models.LightningNode,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
||||
@@ -239,14 +239,14 @@ type DB interface {
|
||||
// FetchLightningNode attempts to look up a target node by its identity
|
||||
// public key. If the node isn't found in the database, then
|
||||
// ErrGraphNodeNotFound is returned.
|
||||
FetchLightningNode(nodePub route.Vertex) (*graphdb.LightningNode,
|
||||
FetchLightningNode(nodePub route.Vertex) (*models.LightningNode,
|
||||
error)
|
||||
|
||||
// ForEachNode iterates through all the stored vertices/nodes in the
|
||||
// graph, executing the passed callback with each node encountered. If
|
||||
// the callback returns an error, then the transaction is aborted and
|
||||
// the iteration stops early.
|
||||
ForEachNode(cb func(kvdb.RTx, *graphdb.LightningNode) error) error
|
||||
ForEachNode(cb func(kvdb.RTx, *models.LightningNode) error) error
|
||||
|
||||
// ForEachNodeChannel iterates through all channels of the given node,
|
||||
// executing the passed callback with an edge info structure and the
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
graphdb "github.com/lightningnetwork/lnd/graph/db"
|
||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
@@ -318,7 +317,7 @@ func addToTopologyChange(graph DB, update *TopologyChange,
|
||||
|
||||
// Any node announcement maps directly to a NetworkNodeUpdate struct.
|
||||
// No further data munging or db queries are required.
|
||||
case *graphdb.LightningNode:
|
||||
case *models.LightningNode:
|
||||
pubKey, err := m.PubKey()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -77,14 +77,14 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func createTestNode(t *testing.T) *graphdb.LightningNode {
|
||||
func createTestNode(t *testing.T) *models.LightningNode {
|
||||
updateTime := prand.Int63()
|
||||
|
||||
priv, err := btcec.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
pub := priv.PubKey().SerializeCompressed()
|
||||
n := &graphdb.LightningNode{
|
||||
n := &models.LightningNode{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(updateTime, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -99,7 +99,7 @@ func createTestNode(t *testing.T) *graphdb.LightningNode {
|
||||
}
|
||||
|
||||
func randEdgePolicy(chanID *lnwire.ShortChannelID,
|
||||
node *graphdb.LightningNode) (*models.ChannelEdgePolicy, error) {
|
||||
node *models.LightningNode) (*models.ChannelEdgePolicy, error) {
|
||||
|
||||
InboundFee := models.InboundFee{
|
||||
Base: prand.Int31() * -1,
|
||||
@@ -686,7 +686,7 @@ func TestNodeUpdateNotification(t *testing.T) {
|
||||
t.Fatalf("unable to add node: %v", err)
|
||||
}
|
||||
|
||||
assertNodeNtfnCorrect := func(t *testing.T, ann *graphdb.LightningNode,
|
||||
assertNodeNtfnCorrect := func(t *testing.T, ann *models.LightningNode,
|
||||
nodeUpdate *NetworkNodeUpdate) {
|
||||
|
||||
nodeKey, _ := ann.PubKey()
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
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"
|
||||
@@ -151,7 +150,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
|
||||
case *lnwire.NodeAnnouncement:
|
||||
// TODO(roasbeef): node ann needs to wait on existing channel updates
|
||||
return
|
||||
case *graphdb.LightningNode:
|
||||
case *models.LightningNode:
|
||||
return
|
||||
case *lnwire.AnnounceSignatures1:
|
||||
// TODO(roasbeef): need to wait on chan ann?
|
||||
@@ -195,7 +194,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
|
||||
jobDesc = fmt.Sprintf("job=lnwire.ChannelEdgePolicy, scid=%v",
|
||||
msg.ChannelID)
|
||||
|
||||
case *graphdb.LightningNode:
|
||||
case *models.LightningNode:
|
||||
vertex := route.Vertex(msg.PubKeyBytes)
|
||||
signals, ok = v.nodeAnnDependencies[vertex]
|
||||
|
||||
@@ -291,7 +290,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
|
||||
// For all other job types, we'll delete the tracking entries from the
|
||||
// map, as if we reach this point, then all dependants have already
|
||||
// finished executing and we can proceed.
|
||||
case *graphdb.LightningNode:
|
||||
case *models.LightningNode:
|
||||
delete(v.nodeAnnDependencies, route.Vertex(msg.PubKeyBytes))
|
||||
case *lnwire.NodeAnnouncement:
|
||||
delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID))
|
||||
|
||||
Reference in new issue
Block a user