From ec332086cd23105783c69c36acbabc52adf24a58 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 21 Aug 2024 11:46:18 +0200 Subject: [PATCH] multi: rename ChannelEdgeInfo In preparaion for adding ChannelEdgeInfo2 and a ChannelEdgeInfo interface, rename ChannelEdgeInfo to ChannelEdgeInfo1. --- autopilot/graph.go | 4 +- channeldb/channel_cache_test.go | 2 +- channeldb/graph.go | 90 ++++++++++++------------ channeldb/graph_cache.go | 8 +-- channeldb/graph_cache_test.go | 6 +- channeldb/graph_test.go | 43 +++++------ channeldb/models/channel_edge_info.go | 20 +++--- discovery/gossiper.go | 20 +++--- discovery/gossiper_test.go | 14 ++-- graph/builder.go | 16 ++--- graph/builder_test.go | 30 ++++---- graph/interfaces.go | 20 +++--- graph/notifications.go | 4 +- graph/notifications_test.go | 8 +-- graph/validation_barrier.go | 6 +- lnrpc/devrpc/dev_server.go | 2 +- lnrpc/invoicesrpc/addinvoice.go | 2 +- lnrpc/invoicesrpc/addinvoice_test.go | 30 ++++---- netann/chan_status_manager_test.go | 12 ++-- netann/channel_announcement.go | 2 +- netann/channel_announcement_test.go | 2 +- netann/channel_update.go | 6 +- netann/interface.go | 2 +- routing/blindedpath/blinded_path.go | 2 +- routing/blindedpath/blinded_path_test.go | 6 +- routing/localchans/manager.go | 4 +- routing/localchans/manager_test.go | 12 ++-- routing/pathfind_test.go | 4 +- routing/router_test.go | 4 +- rpcserver.go | 10 +-- server.go | 2 +- 31 files changed, 197 insertions(+), 196 deletions(-) diff --git a/autopilot/graph.go b/autopilot/graph.go index d9dd2df18..3939d3862 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -90,7 +90,7 @@ func (d *dbNode) Addrs() []net.Addr { // NOTE: Part of the autopilot.Node interface. func (d *dbNode) ForEachChannel(cb func(ChannelEdge) error) error { return d.db.ForEachNodeChannelTx(d.tx, d.node.PubKeyBytes, - func(tx kvdb.RTx, ei *models.ChannelEdgeInfo, ep, + func(tx kvdb.RTx, ei *models.ChannelEdgeInfo1, ep, _ *models.ChannelEdgePolicy1) error { // Skip channels for which no outgoing edge policy is @@ -238,7 +238,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey, } chanID := randChanID() - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), Capacity: capacity, } diff --git a/channeldb/channel_cache_test.go b/channeldb/channel_cache_test.go index 7cb857293..d32548a28 100644 --- a/channeldb/channel_cache_test.go +++ b/channeldb/channel_cache_test.go @@ -100,7 +100,7 @@ func assertHasChanEntries(t *testing.T, c *channelCache, start, end uint64) { // channelForInt generates a unique ChannelEdge given an integer. func channelForInt(i uint64) ChannelEdge { return ChannelEdge{ - Info: &models.ChannelEdgeInfo{ + Info: &models.ChannelEdgeInfo1{ ChannelID: i, }, } diff --git a/channeldb/graph.go b/channeldb/graph.go index 232b3a727..522077cdb 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -239,7 +239,7 @@ func NewChannelGraph(db kvdb.Backend, rejectCacheSize, chanCacheSize int, return nil, err } - err = g.ForEachChannel(func(info *models.ChannelEdgeInfo, + err = g.ForEachChannel(func(info *models.ChannelEdgeInfo1, policy1, policy2 *models.ChannelEdgePolicy1) error { g.graphCache.AddChannel(info, policy1, policy2) @@ -419,7 +419,7 @@ func (c *ChannelGraph) NewPathFindTx() (kvdb.RTx, error) { // NOTE: If an edge can't be found, or wasn't advertised, then a nil pointer // for that particular channel edge routing policy will be passed into the // callback. -func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo, +func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { return c.db.View(func(tx kvdb.RTx) error { @@ -489,7 +489,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx, return err } - dbCallback := func(tx kvdb.RTx, e *models.ChannelEdgeInfo, p1, + dbCallback := func(tx kvdb.RTx, e *models.ChannelEdgeInfo1, p1, p2 *models.ChannelEdgePolicy1) error { var cachedInPolicy *models.CachedEdgePolicy @@ -575,7 +575,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex, channels := make(map[uint64]*DirectedChannel) err := c.ForEachNodeChannelTx(tx, node.PubKeyBytes, - func(tx kvdb.RTx, e *models.ChannelEdgeInfo, + func(tx kvdb.RTx, e *models.ChannelEdgeInfo1, p1 *models.ChannelEdgePolicy1, p2 *models.ChannelEdgePolicy1) error { @@ -988,7 +988,7 @@ func (c *ChannelGraph) deleteLightningNode(nodes kvdb.RwBucket, // involved in creation of the channel, and the set of features that the channel // supports. The chanPoint and chanID are used to uniquely identify the edge // globally within the database. -func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo, +func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo1, op ...batch.SchedulerOption) error { var alreadyExists bool @@ -1032,7 +1032,7 @@ func (c *ChannelGraph) AddChannelEdge(edge *models.ChannelEdgeInfo, // addChannelEdge is the private form of AddChannelEdge that allows callers to // utilize an existing db transaction. func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx, - edge *models.ChannelEdgeInfo) error { + edge *models.ChannelEdgeInfo1) error { // Construct the channel's primary key which is the 8-byte channel ID. var chanKey [8]byte @@ -1244,7 +1244,7 @@ func (c *ChannelGraph) HasChannelEdge( // In order to maintain this constraints, we return an error in the scenario // that an edge info hasn't yet been created yet, but someone attempts to update // it. -func (c *ChannelGraph) UpdateChannelEdge(edge *models.ChannelEdgeInfo) error { +func (c *ChannelGraph) UpdateChannelEdge(edge *models.ChannelEdgeInfo1) error { // Construct the channel's primary key which is the 8-byte channel ID. var chanKey [8]byte binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID) @@ -1290,12 +1290,12 @@ const ( // the target block are returned if the function succeeds without error. func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint, blockHash *chainhash.Hash, blockHeight uint32) ( - []*models.ChannelEdgeInfo, error) { + []*models.ChannelEdgeInfo1, error) { c.cacheMu.Lock() defer c.cacheMu.Unlock() - var chansClosed []*models.ChannelEdgeInfo + var chansClosed []*models.ChannelEdgeInfo1 err := kvdb.Update(c.db, func(tx kvdb.RwTx) error { // First grab the edges bucket which houses the information @@ -1550,7 +1550,7 @@ func (c *ChannelGraph) pruneGraphNodes(nodes kvdb.RwBucket, // Channels that were removed from the graph resulting from the // disconnected block are returned. func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) ( - []*models.ChannelEdgeInfo, error) { + []*models.ChannelEdgeInfo1, error) { // Every channel having a ShortChannelID starting at 'height' // will no longer be confirmed. @@ -1572,7 +1572,7 @@ func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) ( defer c.cacheMu.Unlock() // Keep track of the channels that are removed from the graph. - var removedChans []*models.ChannelEdgeInfo + var removedChans []*models.ChannelEdgeInfo1 if err := kvdb.Update(c.db, func(tx kvdb.RwTx) error { edges, err := tx.CreateTopLevelBucket(edgeBucket) @@ -1875,7 +1875,7 @@ func (c *ChannelGraph) HighestChanID() (uint64, error) { // edge as well as each of the known advertised edge policies. type ChannelEdge struct { // Info contains all the static information describing the channel. - Info *models.ChannelEdgeInfo + Info *models.ChannelEdgeInfo1 // Policy1 points to the "first" edge policy of the channel containing // the dynamic information required to properly route through the edge. @@ -2671,7 +2671,7 @@ func (c *ChannelGraph) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex, // the channel. If the channel were to be marked zombie again, it would be // marked with the correct lagging channel since we received an update from only // one side. -func makeZombiePubkeys(info *models.ChannelEdgeInfo, +func makeZombiePubkeys(info *models.ChannelEdgeInfo1, e1, e2 *models.ChannelEdgePolicy1) ([33]byte, [33]byte) { switch { @@ -2979,7 +2979,7 @@ func (c *ChannelGraph) isPublic(tx kvdb.RTx, nodePub route.Vertex, nodeIsPublic := false errDone := errors.New("done") err := c.ForEachNodeChannelTx(tx, nodePub, func(tx kvdb.RTx, - info *models.ChannelEdgeInfo, _ *models.ChannelEdgePolicy1, + info *models.ChannelEdgeInfo1, _ *models.ChannelEdgePolicy1, _ *models.ChannelEdgePolicy1) error { // If this edge doesn't extend to the source node, we'll @@ -3122,7 +3122,7 @@ func (n *graphCacheNode) Features() *lnwire.FeatureVector { // // Unknown policies are passed into the callback as nil values. func (n *graphCacheNode) ForEachChannel(tx kvdb.RTx, - cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + cb func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { return nodeTraversal(tx, n.pubKeyBytes[:], nil, cb) @@ -3183,7 +3183,7 @@ func (c *ChannelGraph) HasLightningNode(nodePub [33]byte) (time.Time, bool, erro // nodeTraversal is used to traverse all channels of a node given by its // public key and passes channel information into the specified callback. func nodeTraversal(tx kvdb.RTx, nodePub []byte, db kvdb.Backend, - cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + cb func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { traversal := func(tx kvdb.RTx) error { @@ -3272,7 +3272,7 @@ func nodeTraversal(tx kvdb.RTx, nodePub []byte, db kvdb.Backend, // // Unknown policies are passed into the callback as nil values. func (c *ChannelGraph) ForEachNodeChannel(nodePub route.Vertex, - cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + cb func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { return nodeTraversal(nil, nodePub[:], c.db, cb) @@ -3292,7 +3292,7 @@ func (c *ChannelGraph) ForEachNodeChannel(nodePub route.Vertex, // be nil and a fresh transaction will be created to execute the graph // traversal. func (c *ChannelGraph) ForEachNodeChannelTx(tx kvdb.RTx, - nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo, + nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { @@ -3304,7 +3304,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.ChannelEdgeInfo1, thisNodeKey []byte) (*LightningNode, error) { // Ensure that the node passed in is actually a member of the channel. @@ -3352,7 +3352,7 @@ func (c *ChannelGraph) FetchOtherNode(tx kvdb.RTx, // computeEdgePolicyKeys is a helper function that can be used to compute the // keys used to index the channel edge policy info for the two nodes of the // edge. The keys for node 1 and node 2 are returned respectively. -func computeEdgePolicyKeys(info *models.ChannelEdgeInfo) ([]byte, []byte) { +func computeEdgePolicyKeys(info *models.ChannelEdgeInfo1) ([]byte, []byte) { var ( node1Key [33 + 8]byte node2Key [33 + 8]byte @@ -3373,11 +3373,11 @@ func computeEdgePolicyKeys(info *models.ChannelEdgeInfo) ([]byte, []byte) { // information for the channel itself is returned as well as two structs that // contain the routing policies for the channel in either direction. func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { var ( - edgeInfo *models.ChannelEdgeInfo + edgeInfo *models.ChannelEdgeInfo1 policy1 *models.ChannelEdgePolicy1 policy2 *models.ChannelEdgePolicy1 ) @@ -3456,13 +3456,13 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) ( // // ErrZombieEdge an be returned if the edge is currently marked as a zombie // within the database. In this case, the ChannelEdgePolicy1's will be nil, and -// the ChannelEdgeInfo will only include the public keys of each node. +// the ChannelEdgeInfo1 will only include the public keys of each node. func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { var ( - edgeInfo *models.ChannelEdgeInfo + edgeInfo *models.ChannelEdgeInfo1 policy1 *models.ChannelEdgePolicy1 policy2 *models.ChannelEdgePolicy1 channelID [8]byte @@ -3515,7 +3515,7 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) ( // populate the edge info with the public keys of each // party as this is the only information we have about // it and return an error signaling so. - edgeInfo = &models.ChannelEdgeInfo{ + edgeInfo = &models.ChannelEdgeInfo1{ NodeKey1Bytes: pubKey1, NodeKey2Bytes: pubKey2, } @@ -4234,7 +4234,7 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) { } func putChanEdgeInfo(edgeIndex kvdb.RwBucket, - edgeInfo *models.ChannelEdgeInfo, chanID [8]byte) error { + edgeInfo *models.ChannelEdgeInfo1, chanID [8]byte) error { var b bytes.Buffer @@ -4302,58 +4302,58 @@ func putChanEdgeInfo(edgeIndex kvdb.RwBucket, } func fetchChanEdgeInfo(edgeIndex kvdb.RBucket, - chanID []byte) (models.ChannelEdgeInfo, error) { + chanID []byte) (models.ChannelEdgeInfo1, error) { edgeInfoBytes := edgeIndex.Get(chanID) if edgeInfoBytes == nil { - return models.ChannelEdgeInfo{}, ErrEdgeNotFound + return models.ChannelEdgeInfo1{}, ErrEdgeNotFound } edgeInfoReader := bytes.NewReader(edgeInfoBytes) return deserializeChanEdgeInfo(edgeInfoReader) } -func deserializeChanEdgeInfo(r io.Reader) (models.ChannelEdgeInfo, error) { +func deserializeChanEdgeInfo(r io.Reader) (models.ChannelEdgeInfo1, error) { var ( err error - edgeInfo models.ChannelEdgeInfo + edgeInfo models.ChannelEdgeInfo1 ) if _, err := io.ReadFull(r, edgeInfo.NodeKey1Bytes[:]); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if _, err := io.ReadFull(r, edgeInfo.NodeKey2Bytes[:]); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if _, err := io.ReadFull(r, edgeInfo.BitcoinKey1Bytes[:]); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if _, err := io.ReadFull(r, edgeInfo.BitcoinKey2Bytes[:]); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } edgeInfo.Features, err = wire.ReadVarBytes(r, 0, 900, "features") if err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } proof := &models.ChannelAuthProof1{} proof.NodeSig1Bytes, err = wire.ReadVarBytes(r, 0, 80, "sigs") if err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } proof.NodeSig2Bytes, err = wire.ReadVarBytes(r, 0, 80, "sigs") if err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } proof.BitcoinSig1Bytes, err = wire.ReadVarBytes(r, 0, 80, "sigs") if err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } proof.BitcoinSig2Bytes, err = wire.ReadVarBytes(r, 0, 80, "sigs") if err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if !proof.IsEmpty() { @@ -4362,17 +4362,17 @@ func deserializeChanEdgeInfo(r io.Reader) (models.ChannelEdgeInfo, error) { edgeInfo.ChannelPoint = wire.OutPoint{} if err := readOutpoint(r, &edgeInfo.ChannelPoint); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if err := binary.Read(r, byteOrder, &edgeInfo.Capacity); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if err := binary.Read(r, byteOrder, &edgeInfo.ChannelID); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } if _, err := io.ReadFull(r, edgeInfo.ChainHash[:]); err != nil { - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } // We'll try and see if there are any opaque bytes left, if not, then @@ -4384,7 +4384,7 @@ func deserializeChanEdgeInfo(r io.Reader) (models.ChannelEdgeInfo, error) { case err == io.ErrUnexpectedEOF: case err == io.EOF: case err != nil: - return models.ChannelEdgeInfo{}, err + return models.ChannelEdgeInfo1{}, err } return edgeInfo, nil diff --git a/channeldb/graph_cache.go b/channeldb/graph_cache.go index 888e2dfa5..7df72b209 100644 --- a/channeldb/graph_cache.go +++ b/channeldb/graph_cache.go @@ -28,7 +28,7 @@ type GraphCacheNode interface { // error, then the iteration is halted with the error propagated back up // to the caller. ForEachChannel(kvdb.RTx, - func(kvdb.RTx, *models.ChannelEdgeInfo, + func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error } @@ -142,7 +142,7 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error { c.AddNodeFeatures(node) return node.ForEachChannel( - tx, func(tx kvdb.RTx, info *models.ChannelEdgeInfo, + tx, func(tx kvdb.RTx, info *models.ChannelEdgeInfo1, outPolicy *models.ChannelEdgePolicy1, inPolicy *models.ChannelEdgePolicy1) error { @@ -157,7 +157,7 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error { // and policy 2 does not matter, the directionality is extracted from the info // and policy flags automatically. The policy will be set as the outgoing policy // on one node and the incoming policy on the peer's side. -func (c *GraphCache) AddChannel(info *models.ChannelEdgeInfo, policy1, +func (c *GraphCache) AddChannel(info *models.ChannelEdgeInfo1, policy1, policy2 *models.ChannelEdgePolicy1) { if info == nil { @@ -309,7 +309,7 @@ func (c *GraphCache) removeChannelIfFound(node route.Vertex, chanID uint64) { // UpdateChannel updates the channel edge information for a specific edge. We // expect the edge to already exist and be known. If it does not yet exist, this // call is a no-op. -func (c *GraphCache) UpdateChannel(info *models.ChannelEdgeInfo) { +func (c *GraphCache) UpdateChannel(info *models.ChannelEdgeInfo1) { c.mtx.Lock() defer c.mtx.Unlock() diff --git a/channeldb/graph_cache_test.go b/channeldb/graph_cache_test.go index e3ba3d67a..65e639be5 100644 --- a/channeldb/graph_cache_test.go +++ b/channeldb/graph_cache_test.go @@ -29,7 +29,7 @@ type node struct { pubKey route.Vertex features *lnwire.FeatureVector - edgeInfos []*models.ChannelEdgeInfo + edgeInfos []*models.ChannelEdgeInfo1 outPolicies []*models.ChannelEdgePolicy1 inPolicies []*models.ChannelEdgePolicy1 } @@ -42,7 +42,7 @@ func (n *node) Features() *lnwire.FeatureVector { } func (n *node) ForEachChannel(tx kvdb.RTx, - cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + cb func(kvdb.RTx, *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { for idx := range n.edgeInfos { @@ -88,7 +88,7 @@ func TestGraphCacheAddNode(t *testing.T) { node := &node{ pubKey: nodeA, features: lnwire.EmptyFeatureVector(), - edgeInfos: []*models.ChannelEdgeInfo{{ + edgeInfos: []*models.ChannelEdgeInfo1{{ ChannelID: 1000, // Those are direction independent! NodeKey1Bytes: pubKey1, diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index 30be2db44..a0c8dae25 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -326,7 +326,7 @@ func TestEdgeInsertionDeletion(t *testing.T) { require.NoError(t, err, "unable to generate node key") node2Pub, err := node2.PubKey() require.NoError(t, err, "unable to generate node key") - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: chanID, ChainHash: key, AuthProof: &models.ChannelAuthProof1{ @@ -386,7 +386,7 @@ func TestEdgeInsertionDeletion(t *testing.T) { } func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32, - node1, node2 *LightningNode) (models.ChannelEdgeInfo, + node1, node2 *LightningNode) (models.ChannelEdgeInfo1, lnwire.ShortChannelID) { shortChanID := lnwire.ShortChannelID{ @@ -401,7 +401,7 @@ func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32, node1Pub, _ := node1.PubKey() node2Pub, _ := node2.PubKey() - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: shortChanID.ToUint64(), ChainHash: key, AuthProof: &models.ChannelAuthProof1{ @@ -556,8 +556,8 @@ func TestDisconnectBlockAtHeight(t *testing.T) { } } -func assertEdgeInfoEqual(t *testing.T, e1 *models.ChannelEdgeInfo, - e2 *models.ChannelEdgeInfo) { +func assertEdgeInfoEqual(t *testing.T, e1 *models.ChannelEdgeInfo1, + e2 *models.ChannelEdgeInfo1) { if e1.ChannelID != e2.ChannelID { t.Fatalf("chan id's don't match: %v vs %v", e1.ChannelID, @@ -619,7 +619,7 @@ func assertEdgeInfoEqual(t *testing.T, e1 *models.ChannelEdgeInfo, } func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) { var ( @@ -644,7 +644,7 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) ( // Add the new edge to the database, this should proceed without any // errors. - edgeInfo := &models.ChannelEdgeInfo{ + edgeInfo := &models.ChannelEdgeInfo1{ ChannelID: chanID, ChainHash: key, AuthProof: &models.ChannelAuthProof1{ @@ -821,7 +821,7 @@ func assertNodeNotInCache(t *testing.T, g *ChannelGraph, n route.Vertex) { } func assertEdgeWithNoPoliciesInCache(t *testing.T, g *ChannelGraph, - e *models.ChannelEdgeInfo) { + e *models.ChannelEdgeInfo1) { // Let's check the internal view first. require.NotEmpty(t, g.graphCache.nodeChannels[e.NodeKey1Bytes]) @@ -899,7 +899,8 @@ func assertNoEdge(t *testing.T, g *ChannelGraph, chanID uint64) { } func assertEdgeWithPolicyInCache(t *testing.T, g *ChannelGraph, - e *models.ChannelEdgeInfo, p *models.ChannelEdgePolicy1, policy1 bool) { + e *models.ChannelEdgeInfo1, p *models.ChannelEdgePolicy1, + policy1 bool) { // Check the internal state first. c1, ok := g.graphCache.nodeChannels[e.NodeKey1Bytes][e.ChannelID] @@ -1041,7 +1042,7 @@ func TestGraphTraversal(t *testing.T) { // Iterate through all the known channels within the graph DB, once // again if the map is empty that indicates that all edges have // properly been reached. - err = graph.ForEachChannel(func(ei *models.ChannelEdgeInfo, + err = graph.ForEachChannel(func(ei *models.ChannelEdgeInfo1, _ *models.ChannelEdgePolicy1, _ *models.ChannelEdgePolicy1) error { @@ -1056,7 +1057,7 @@ func TestGraphTraversal(t *testing.T) { numNodeChans := 0 firstNode, secondNode := nodeList[0], nodeList[1] err = graph.ForEachNodeChannel(firstNode.PubKeyBytes, - func(_ kvdb.RTx, _ *models.ChannelEdgeInfo, outEdge, + func(_ kvdb.RTx, _ *models.ChannelEdgeInfo1, outEdge, inEdge *models.ChannelEdgePolicy1) error { // All channels between first and second node should @@ -1137,7 +1138,7 @@ func TestGraphTraversalCacheable(t *testing.T) { for _, node := range nodes { err := node.ForEachChannel( tx, func(tx kvdb.RTx, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, policy *models.ChannelEdgePolicy1, policy2 *models.ChannelEdgePolicy1) error { //nolint:lll @@ -1257,7 +1258,7 @@ func fillTestGraph(t require.TestingT, graph *ChannelGraph, numNodes, Index: 0, } - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: chanID, ChainHash: key, AuthProof: &models.ChannelAuthProof1{ @@ -1321,7 +1322,7 @@ func assertPruneTip(t *testing.T, graph *ChannelGraph, blockHash *chainhash.Hash func assertNumChans(t *testing.T, graph *ChannelGraph, n int) { numChans := 0 - if err := graph.ForEachChannel(func(*models.ChannelEdgeInfo, + if err := graph.ForEachChannel(func(*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error { @@ -1439,7 +1440,7 @@ func TestGraphPruning(t *testing.T) { channelPoints = append(channelPoints, &op) - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: chanID, ChainHash: key, AuthProof: &models.ChannelAuthProof1{ @@ -2120,7 +2121,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) { require.NoError(t, err) type chanInfo struct { - info models.ChannelEdgeInfo + info models.ChannelEdgeInfo1 id lnwire.ShortChannelID } @@ -2748,7 +2749,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { checkPolicies := func(node *LightningNode, expectedIn, expectedOut bool) { calls := 0 err := graph.ForEachNodeChannel(node.PubKeyBytes, - func(_ kvdb.RTx, _ *models.ChannelEdgeInfo, outEdge, + func(_ kvdb.RTx, _ *models.ChannelEdgeInfo1, outEdge, inEdge *models.ChannelEdgePolicy1) error { if !expectedOut && outEdge != nil { @@ -3166,7 +3167,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} - edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge} + edges := []*models.ChannelEdgeInfo1{&aliceBobEdge, &bobCarolEdge} graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph} for _, graph := range graphs { for _, node := range nodes { @@ -3770,7 +3771,7 @@ func TestBatchedAddChannelEdge(t *testing.T) { // Create a third edge, this with a block height of 155. edgeInfo3, _ := createEdge(height-1, 0, 0, 2, node1, node2) - edges := []models.ChannelEdgeInfo{edgeInfo, edgeInfo2, edgeInfo3} + edges := []models.ChannelEdgeInfo1{edgeInfo, edgeInfo2, edgeInfo3} errChan := make(chan error, len(edges)) errTimeout := errors.New("timeout adding batched channel") @@ -3778,7 +3779,7 @@ func TestBatchedAddChannelEdge(t *testing.T) { var wg sync.WaitGroup for _, edge := range edges { wg.Add(1) - go func(edge models.ChannelEdgeInfo) { + go func(edge models.ChannelEdgeInfo1) { defer wg.Done() select { @@ -3886,7 +3887,7 @@ func BenchmarkForEachChannel(b *testing.B) { err = graph.db.View(func(tx kvdb.RTx) error { for _, n := range nodes { cb := func(tx kvdb.RTx, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, policy *models.ChannelEdgePolicy1, policy2 *models.ChannelEdgePolicy1) error { //nolint:lll diff --git a/channeldb/models/channel_edge_info.go b/channeldb/models/channel_edge_info.go index 24aec1e7a..5a8dc6791 100644 --- a/channeldb/models/channel_edge_info.go +++ b/channeldb/models/channel_edge_info.go @@ -10,13 +10,13 @@ import ( "github.com/btcsuite/btcd/wire" ) -// ChannelEdgeInfo represents a fully authenticated channel along with all its +// ChannelEdgeInfo1 represents a fully authenticated channel along with all its // unique attributes. Once an authenticated channel announcement has been -// processed on the network, then an instance of ChannelEdgeInfo encapsulating +// processed on the network, then an instance of ChannelEdgeInfo1 encapsulating // the channels attributes is stored. The other portions relevant to routing // policy of a channel are stored within a ChannelEdgePolicy1 for each direction // of the channel. -type ChannelEdgeInfo struct { +type ChannelEdgeInfo1 struct { // ChannelID is the unique channel ID for the channel. The first 3 // bytes are the block height, the next 3 the index within the block, // and the last 2 bytes are the output index for the channel. @@ -72,8 +72,8 @@ type ChannelEdgeInfo struct { } // AddNodeKeys is a setter-like method that can be used to replace the set of -// keys for the target ChannelEdgeInfo. -func (c *ChannelEdgeInfo) AddNodeKeys(nodeKey1, nodeKey2, bitcoinKey1, +// keys for the target ChannelEdgeInfo1. +func (c *ChannelEdgeInfo1) AddNodeKeys(nodeKey1, nodeKey2, bitcoinKey1, bitcoinKey2 *btcec.PublicKey) { c.nodeKey1 = nodeKey1 @@ -96,7 +96,7 @@ func (c *ChannelEdgeInfo) AddNodeKeys(nodeKey1, nodeKey2, bitcoinKey1, // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the pubkey if absolutely necessary. -func (c *ChannelEdgeInfo) NodeKey1() (*btcec.PublicKey, error) { +func (c *ChannelEdgeInfo1) NodeKey1() (*btcec.PublicKey, error) { if c.nodeKey1 != nil { return c.nodeKey1, nil } @@ -117,7 +117,7 @@ func (c *ChannelEdgeInfo) NodeKey1() (*btcec.PublicKey, error) { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the pubkey if absolutely necessary. -func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error) { +func (c *ChannelEdgeInfo1) NodeKey2() (*btcec.PublicKey, error) { if c.nodeKey2 != nil { return c.nodeKey2, nil } @@ -137,7 +137,7 @@ func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error) { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the pubkey if absolutely necessary. -func (c *ChannelEdgeInfo) BitcoinKey1() (*btcec.PublicKey, error) { +func (c *ChannelEdgeInfo1) BitcoinKey1() (*btcec.PublicKey, error) { if c.bitcoinKey1 != nil { return c.bitcoinKey1, nil } @@ -157,7 +157,7 @@ func (c *ChannelEdgeInfo) BitcoinKey1() (*btcec.PublicKey, error) { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the pubkey if absolutely necessary. -func (c *ChannelEdgeInfo) BitcoinKey2() (*btcec.PublicKey, error) { +func (c *ChannelEdgeInfo1) BitcoinKey2() (*btcec.PublicKey, error) { if c.bitcoinKey2 != nil { return c.bitcoinKey2, nil } @@ -172,7 +172,7 @@ func (c *ChannelEdgeInfo) BitcoinKey2() (*btcec.PublicKey, error) { } // OtherNodeKeyBytes returns the node key bytes of the other end of the channel. -func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) ( +func (c *ChannelEdgeInfo1) OtherNodeKeyBytes(thisNodeKey []byte) ( [33]byte, error) { switch { diff --git a/discovery/gossiper.go b/discovery/gossiper.go index af6ca7935..2177b8cfa 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -553,7 +553,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper // EdgeWithInfo contains the information that is required to update an edge. type EdgeWithInfo struct { // Info describes the channel. - Info *models.ChannelEdgeInfo + Info *models.ChannelEdgeInfo1 // Edge describes the policy in one direction of the channel. Edge *models.ChannelEdgePolicy1 @@ -1617,7 +1617,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { // Iterate over all of our channels and check if any of them fall // within the prune interval or re-broadcast interval. type updateTuple struct { - info *models.ChannelEdgeInfo + info *models.ChannelEdgeInfo1 edge *models.ChannelEdgePolicy1 } @@ -1627,7 +1627,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { ) err := d.cfg.Graph.ForAllOutgoingChannels(func( _ kvdb.RTx, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, edge *models.ChannelEdgePolicy1) error { // If there's no auth proof attached to this edge, it means @@ -1833,8 +1833,8 @@ func (d *AuthenticatedGossiper) processChanPolicyUpdate( } // remotePubFromChanInfo returns the public key of the remote peer given a -// ChannelEdgeInfo that describe a channel we have with them. -func remotePubFromChanInfo(chanInfo *models.ChannelEdgeInfo, +// ChannelEdgeInfo1 that describe a channel we have with them. +func remotePubFromChanInfo(chanInfo *models.ChannelEdgeInfo1, chanFlags lnwire.ChanUpdateChanFlags) [33]byte { var remotePubKey [33]byte @@ -2073,10 +2073,10 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement( // processZombieUpdate determines whether the provided channel update should // resurrect a given zombie edge. // -// NOTE: only the NodeKey1Bytes and NodeKey2Bytes members of the ChannelEdgeInfo -// should be inspected. +// NOTE: only the NodeKey1Bytes and NodeKey2Bytes members of the +// ChannelEdgeInfo1 should be inspected. func (d *AuthenticatedGossiper) processZombieUpdate( - chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID, + chanInfo *models.ChannelEdgeInfo1, scid lnwire.ShortChannelID, msg *lnwire.ChannelUpdate1) error { // The least-significant bit in the flag on the channel update tells us @@ -2213,7 +2213,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool { // updateChannel creates a new fully signed update for the channel, and updates // the underlying graph with the new state. -func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo, +func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo1, edge *models.ChannelEdgePolicy1) (*lnwire.ChannelAnnouncement1, *lnwire.ChannelUpdate1, error) { @@ -2575,7 +2575,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg, return nil, false } - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: scid.ToUint64(), ChainHash: ann.ChainHash, NodeKey1Bytes: ann.NodeID1, diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 1aa44591e..3dc946193 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -93,7 +93,7 @@ type mockGraphSource struct { mu sync.Mutex nodes []channeldb.LightningNode - infos map[uint64]models.ChannelEdgeInfo + infos map[uint64]models.ChannelEdgeInfo1 edges map[uint64][]models.ChannelEdgePolicy1 zombies map[uint64][][33]byte chansToReject map[uint64]struct{} @@ -103,7 +103,7 @@ type mockGraphSource struct { func newMockRouter(height uint32) *mockGraphSource { return &mockGraphSource{ bestHeight: height, - infos: make(map[uint64]models.ChannelEdgeInfo), + infos: make(map[uint64]models.ChannelEdgeInfo1), edges: make(map[uint64][]models.ChannelEdgePolicy1), zombies: make(map[uint64][][33]byte), chansToReject: make(map[uint64]struct{}), @@ -122,7 +122,7 @@ func (r *mockGraphSource) AddNode(node *channeldb.LightningNode, return nil } -func (r *mockGraphSource) AddEdge(info *models.ChannelEdgeInfo, +func (r *mockGraphSource) AddEdge(info *models.ChannelEdgeInfo1, _ ...batch.SchedulerOption) error { r.mu.Lock() @@ -207,7 +207,7 @@ func (r *mockGraphSource) ForEachNode(func(node *channeldb.LightningNode) error) } func (r *mockGraphSource) ForAllOutgoingChannels(cb func(tx kvdb.RTx, - i *models.ChannelEdgeInfo, + i *models.ChannelEdgeInfo1, c *models.ChannelEdgePolicy1) error) error { r.mu.Lock() @@ -239,7 +239,7 @@ func (r *mockGraphSource) ForAllOutgoingChannels(cb func(tx kvdb.RTx, } func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( - *models.ChannelEdgeInfo, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { @@ -254,7 +254,7 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( return nil, nil, nil, channeldb.ErrEdgeNotFound } - return &models.ChannelEdgeInfo{ + return &models.ChannelEdgeInfo1{ NodeKey1Bytes: pubKeys[0], NodeKey2Bytes: pubKeys[1], }, nil, nil, channeldb.ErrZombieEdge @@ -3483,7 +3483,7 @@ out: var edgesToUpdate []EdgeWithInfo err = ctx.router.ForAllOutgoingChannels(func( _ kvdb.RTx, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, edge *models.ChannelEdgePolicy1) error { edge.TimeLockDelta = uint16(newTimeLockDelta) diff --git a/graph/builder.go b/graph/builder.go index 8d92cb6a3..4cd0c4600 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -540,14 +540,14 @@ func (b *Builder) pruneZombieChans() error { log.Infof("Examining channel graph for zombie channels") // A helper method to detect if the channel belongs to this node - isSelfChannelEdge := func(info *models.ChannelEdgeInfo) bool { + isSelfChannelEdge := func(info *models.ChannelEdgeInfo1) bool { return info.NodeKey1Bytes == b.cfg.SelfNode || info.NodeKey2Bytes == b.cfg.SelfNode } // First, we'll collect all the channels which are eligible for garbage // collection due to being zombies. - filterPruneChans := func(info *models.ChannelEdgeInfo, + filterPruneChans := func(info *models.ChannelEdgeInfo1, e1, e2 *models.ChannelEdgePolicy1) error { // Exit early in case this channel is already marked to be @@ -1181,8 +1181,8 @@ func (b *Builder) processUpdate(msg interface{}, log.Tracef("Updated vertex data for node=%x", msg.PubKeyBytes) b.stats.incNumNodeUpdates() - case *models.ChannelEdgeInfo: - log.Debugf("Received ChannelEdgeInfo for channel %v", + case *models.ChannelEdgeInfo1: + log.Debugf("Received ChannelEdgeInfo1 for channel %v", msg.ChannelID) // Prior to processing the announcement we first check if we @@ -1543,7 +1543,7 @@ func (b *Builder) AddNode(node *channeldb.LightningNode, // in construction of payment path. // // NOTE: This method is part of the ChannelGraphSource interface. -func (b *Builder) AddEdge(edge *models.ChannelEdgeInfo, +func (b *Builder) AddEdge(edge *models.ChannelEdgeInfo1, op ...batch.SchedulerOption) error { rMsg := &routingMsg{ @@ -1610,7 +1610,7 @@ func (b *Builder) SyncedHeight() uint32 { // // NOTE: This method is part of the ChannelGraphSource interface. func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) ( - *models.ChannelEdgeInfo, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { @@ -1645,10 +1645,10 @@ func (b *Builder) ForEachNode( // // NOTE: This method is part of the ChannelGraphSource interface. func (b *Builder) ForAllOutgoingChannels(cb func(kvdb.RTx, - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1) error) error { + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1) error) error { return b.cfg.Graph.ForEachNodeChannel(b.cfg.SelfNode, - func(tx kvdb.RTx, c *models.ChannelEdgeInfo, + func(tx kvdb.RTx, c *models.ChannelEdgeInfo1, e *models.ChannelEdgePolicy1, _ *models.ChannelEdgePolicy1) error { diff --git a/graph/builder_test.go b/graph/builder_test.go index a8b94ee39..8e7cca9e0 100644 --- a/graph/builder_test.go +++ b/graph/builder_test.go @@ -63,7 +63,7 @@ func TestAddProof(t *testing.T) { ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight) // After utxo was recreated adding the edge without the proof. - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -146,7 +146,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) { } ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight) - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: pub1, NodeKey2Bytes: pub2, @@ -259,7 +259,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) { node1 := createTestNode(t) node2 := createTestNode(t) - edge1 := &models.ChannelEdgeInfo{ + edge1 := &models.ChannelEdgeInfo1{ ChannelID: chanID1, NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -277,7 +277,7 @@ func TestWakeUpOnStaleBranch(t *testing.T) { t.Fatalf("unable to add edge: %v", err) } - edge2 := &models.ChannelEdgeInfo{ + edge2 := &models.ChannelEdgeInfo1{ ChannelID: chanID2, NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -462,7 +462,7 @@ func TestDisconnectedBlocks(t *testing.T) { node1 := createTestNode(t) node2 := createTestNode(t) - edge1 := &models.ChannelEdgeInfo{ + edge1 := &models.ChannelEdgeInfo1{ ChannelID: chanID1, NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -482,7 +482,7 @@ func TestDisconnectedBlocks(t *testing.T) { t.Fatalf("unable to add edge: %v", err) } - edge2 := &models.ChannelEdgeInfo{ + edge2 := &models.ChannelEdgeInfo1{ ChannelID: chanID2, NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -612,7 +612,7 @@ func TestRouterChansClosedOfflinePruneGraph(t *testing.T) { node1 := createTestNode(t) node2 := createTestNode(t) - edge1 := &models.ChannelEdgeInfo{ + edge1 := &models.ChannelEdgeInfo1{ ChannelID: chanID1.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -1017,7 +1017,7 @@ func TestIsStaleNode(t *testing.T) { } ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight) - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: pub1, NodeKey2Bytes: pub2, @@ -1093,7 +1093,7 @@ func TestIsKnownEdge(t *testing.T) { } ctx.chain.addBlock(fundingBlock, chanID.BlockHeight, chanID.BlockHeight) - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: pub1, NodeKey2Bytes: pub2, @@ -1149,7 +1149,7 @@ func TestIsStaleEdgePolicy(t *testing.T) { t.Fatalf("router failed to detect fresh edge policy") } - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: pub1, NodeKey2Bytes: pub2, @@ -1231,7 +1231,7 @@ const ( // newChannelEdgeInfo is a helper function used to create a new channel edge, // possibly skipping adding it to parts of the chain/state as well. func newChannelEdgeInfo(t *testing.T, ctx *testCtx, fundingHeight uint32, - ecm edgeCreationModifier) (*models.ChannelEdgeInfo, error) { + ecm edgeCreationModifier) (*models.ChannelEdgeInfo1, error) { node1 := createTestNode(t) node2 := createTestNode(t) @@ -1244,7 +1244,7 @@ func newChannelEdgeInfo(t *testing.T, ctx *testCtx, fundingHeight uint32, return nil, fmt.Errorf("unable to create edge: %w", err) } - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -1275,7 +1275,7 @@ func newChannelEdgeInfo(t *testing.T, ctx *testCtx, fundingHeight uint32, } func assertChanChainRejection(t *testing.T, ctx *testCtx, - edge *models.ChannelEdgeInfo, failCode ErrorCode) { + edge *models.ChannelEdgeInfo1, failCode ErrorCode) { t.Helper() @@ -1573,7 +1573,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( // We first insert the existence of the edge between the two // nodes. - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: edge.ChannelID, AuthProof: &testAuthProof, ChannelPoint: fundingPoint, @@ -1945,7 +1945,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, // We first insert the existence of the edge between the two // nodes. - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: channelID, AuthProof: &testAuthProof, ChannelPoint: *fundingPoint, diff --git a/graph/interfaces.go b/graph/interfaces.go index 3408b366a..43ed155aa 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -29,7 +29,7 @@ type ChannelGraphSource interface { // AddEdge is used to add edge/channel to the topology of the router, // after all information about channel will be gathered this // edge/channel might be used in construction of payment path. - AddEdge(edge *models.ChannelEdgeInfo, + AddEdge(edge *models.ChannelEdgeInfo1, op ...batch.SchedulerOption) error // AddProof updates the channel edge info with proof which is needed to @@ -70,7 +70,7 @@ type ChannelGraphSource interface { // emanating from the "source" node which is the center of the // star-graph. ForAllOutgoingChannels(cb func(tx kvdb.RTx, - c *models.ChannelEdgeInfo, + c *models.ChannelEdgeInfo1, e *models.ChannelEdgePolicy1) error) error // CurrentBlockHeight returns the block height from POV of the router @@ -79,7 +79,7 @@ type ChannelGraphSource interface { // GetChannelByID return the channel by the channel id. GetChannelByID(chanID lnwire.ShortChannelID) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // FetchLightningNode attempts to look up a target node by its identity @@ -110,7 +110,7 @@ type DB interface { // slice of channels that have been closed by the target block are // returned if the function succeeds without error. PruneGraph(spentOutputs []*wire.OutPoint, blockHash *chainhash.Hash, - blockHeight uint32) ([]*models.ChannelEdgeInfo, error) + blockHeight uint32) ([]*models.ChannelEdgeInfo1, error) // ChannelView returns the verifiable edge information for each active // channel within the known channel graph. The set of UTXO's (along with @@ -169,7 +169,7 @@ type DB interface { // set to the last prune height valid for the remaining chain. // Channels that were removed from the graph resulting from the // disconnected block are returned. - DisconnectBlockAtHeight(height uint32) ([]*models.ChannelEdgeInfo, + DisconnectBlockAtHeight(height uint32) ([]*models.ChannelEdgeInfo1, error) // HasChannelEdge returns true if the database knows of a channel edge @@ -189,9 +189,9 @@ type DB interface { // // ErrZombieEdge an be returned if the edge is currently marked as a // zombie within the database. In this case, the ChannelEdgePolicy1's - // will be nil, and the ChannelEdgeInfo will only include the public + // will be nil, and the ChannelEdgeInfo1 will only include the public // keys of each node. - FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo, + FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // AddLightningNode adds a vertex/node to the graph database. If the @@ -210,7 +210,7 @@ type DB interface { // and the set of features that the channel supports. The chanPoint and // chanID are used to uniquely identify the edge globally within the // database. - AddChannelEdge(edge *models.ChannelEdgeInfo, + AddChannelEdge(edge *models.ChannelEdgeInfo1, op ...batch.SchedulerOption) error // MarkEdgeZombie attempts to mark a channel identified by its channel @@ -258,7 +258,7 @@ type DB interface { // // Unknown policies are passed into the callback as nil values. ForEachNodeChannel(nodePub route.Vertex, cb func(kvdb.RTx, - *models.ChannelEdgeInfo, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error @@ -267,7 +267,7 @@ type DB interface { // created. In order to maintain this constraints, we return an error in // the scenario that an edge info hasn't yet been created yet, but // someone attempts to update it. - UpdateChannelEdge(edge *models.ChannelEdgeInfo) error + UpdateChannelEdge(edge *models.ChannelEdgeInfo1) error // IsPublicNode is a helper method that determines whether the node with // the given public key is seen as a public node in the graph from the diff --git a/graph/notifications.go b/graph/notifications.go index 2873a08b3..47e1c62f6 100644 --- a/graph/notifications.go +++ b/graph/notifications.go @@ -211,7 +211,7 @@ type ClosedChanSummary struct { // createCloseSummaries takes in a slice of channels closed at the target block // height and creates a slice of summaries which of each channel closure. func createCloseSummaries(blockHeight uint32, - closedChans ...*models.ChannelEdgeInfo) []*ClosedChanSummary { + closedChans ...*models.ChannelEdgeInfo1) []*ClosedChanSummary { closeSummaries := make([]*ClosedChanSummary, len(closedChans)) for i, closedChan := range closedChans { @@ -337,7 +337,7 @@ func addToTopologyChange(graph DB, update *TopologyChange, // We ignore initial channel announcements as we'll only send out // updates once the individual edges themselves have been updated. - case *models.ChannelEdgeInfo: + case *models.ChannelEdgeInfo1: return nil // Any new ChannelUpdateAnnouncements will generate a corresponding diff --git a/graph/notifications_test.go b/graph/notifications_test.go index 34bbd5423..8cba544cd 100644 --- a/graph/notifications_test.go +++ b/graph/notifications_test.go @@ -466,7 +466,7 @@ func TestEdgeUpdateNotification(t *testing.T) { // Finally, to conclude our test set up, we'll create a channel // update to announce the created channel between the two nodes. - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -653,7 +653,7 @@ func TestNodeUpdateNotification(t *testing.T) { testFeaturesBuf := new(bytes.Buffer) require.NoError(t, testFeatures.Encode(testFeaturesBuf)) - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -837,7 +837,7 @@ func TestNotificationCancellation(t *testing.T) { // to the client. ntfnClient.Cancel() - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, @@ -906,7 +906,7 @@ func TestChannelCloseNotification(t *testing.T) { // Finally, to conclude our test set up, we'll create a channel // announcement to announce the created channel between the two nodes. - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: node1.PubKeyBytes, NodeKey2Bytes: node2.PubKeyBytes, diff --git a/graph/validation_barrier.go b/graph/validation_barrier.go index 513fb28de..2bfc85f06 100644 --- a/graph/validation_barrier.go +++ b/graph/validation_barrier.go @@ -126,7 +126,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) { v.nodeAnnDependencies[route.Vertex(msg.NodeID1)] = signals v.nodeAnnDependencies[route.Vertex(msg.NodeID2)] = signals } - case *models.ChannelEdgeInfo: + case *models.ChannelEdgeInfo1: shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) if _, ok := v.chanAnnFinSignal[shortID]; !ok { @@ -218,7 +218,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error { // return directly. case *lnwire.AnnounceSignatures1: // TODO(roasbeef): need to wait on chan ann? - case *models.ChannelEdgeInfo: + case *models.ChannelEdgeInfo1: case *lnwire.ChannelAnnouncement1: } @@ -264,7 +264,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) { // If we've just finished executing a ChannelAnnouncement, then we'll // close out the signal, and remove the signal from the map of active // ones. This will allow/deny any dependent jobs to continue execution. - case *models.ChannelEdgeInfo: + case *models.ChannelEdgeInfo1: shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) finSignals, ok := v.chanAnnFinSignal[shortID] if ok { diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index 07c242316..97384a679 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -262,7 +262,7 @@ func (s *Server) ImportGraph(ctx context.Context, for _, rpcEdge := range graph.Edges { rpcEdge := rpcEdge - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: rpcEdge.ChannelId, ChainHash: *s.cfg.ActiveNetParams.GenesisHash, Capacity: btcutil.Amount(rpcEdge.Capacity), diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index cb8cb82e2..180c81f68 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -762,7 +762,7 @@ type SelectHopHintsCfg struct { // FetchChannelEdgesByID attempts to lookup the two directed edges for // the channel identified by the channel ID. - FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo, + FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) diff --git a/lnrpc/invoicesrpc/addinvoice_test.go b/lnrpc/invoicesrpc/addinvoice_test.go index 5d4fd7e0d..2bb94da8b 100644 --- a/lnrpc/invoicesrpc/addinvoice_test.go +++ b/lnrpc/invoicesrpc/addinvoice_test.go @@ -67,7 +67,7 @@ func (h *hopHintsConfigMock) FetchAllChannels() ([]*channeldb.OpenChannel, // FetchChannelEdgesByID attempts to lookup the two directed edges for // the channel identified by the channel ID. func (h *hopHintsConfigMock) FetchChannelEdgesByID(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { args := h.Mock.Called(chanID) @@ -80,7 +80,7 @@ func (h *hopHintsConfigMock) FetchChannelEdgesByID(chanID uint64) ( return nil, nil, nil, err } - edgeInfo, ok := args.Get(0).(*models.ChannelEdgeInfo) + edgeInfo, ok := args.Get(0).(*models.ChannelEdgeInfo1) require.True(h.t, ok) policy1, ok := args.Get(1).(*models.ChannelEdgePolicy1) @@ -226,7 +226,7 @@ var shouldIncludeChannelTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -264,7 +264,7 @@ var shouldIncludeChannelTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -305,7 +305,7 @@ var shouldIncludeChannelTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{ + &models.ChannelEdgeInfo1{ NodeKey1Bytes: selectedPolicy, }, &models.ChannelEdgePolicy1{ @@ -353,7 +353,7 @@ var shouldIncludeChannelTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{ FeeBaseMSat: 1000, @@ -398,7 +398,7 @@ var shouldIncludeChannelTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{ FeeBaseMSat: 1000, @@ -565,7 +565,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -615,7 +615,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -666,7 +666,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -699,7 +699,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -716,7 +716,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -753,7 +753,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -770,7 +770,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) @@ -808,7 +808,7 @@ var populateHopHintsTestCases = []struct { h.Mock.On( "FetchChannelEdgesByID", mock.Anything, ).Once().Return( - &models.ChannelEdgeInfo{}, + &models.ChannelEdgeInfo1{}, &models.ChannelEdgePolicy1{}, &models.ChannelEdgePolicy1{}, nil, ) diff --git a/netann/chan_status_manager_test.go b/netann/chan_status_manager_test.go index 46e1939fe..7af98bd80 100644 --- a/netann/chan_status_manager_test.go +++ b/netann/chan_status_manager_test.go @@ -66,7 +66,7 @@ func createChannel(t *testing.T) *channeldb.OpenChannel { // our `pubkey` with the direction bit set appropriately in the policies. Our // update will be created with the disabled bit set if startEnabled is false. func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel, - pubkey *btcec.PublicKey, startEnabled bool) (*models.ChannelEdgeInfo, + pubkey *btcec.PublicKey, startEnabled bool) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) { var ( @@ -99,7 +99,7 @@ func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel, // bit. dir2 |= lnwire.ChanUpdateDirection - return &models.ChannelEdgeInfo{ + return &models.ChannelEdgeInfo1{ ChannelPoint: channel.FundingOutpoint, NodeKey1Bytes: pubkey1, NodeKey2Bytes: pubkey2, @@ -121,7 +121,7 @@ func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel, type mockGraph struct { mu sync.Mutex channels []*channeldb.OpenChannel - chanInfos map[wire.OutPoint]*models.ChannelEdgeInfo + chanInfos map[wire.OutPoint]*models.ChannelEdgeInfo1 chanPols1 map[wire.OutPoint]*models.ChannelEdgePolicy1 chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy1 sidToCid map[lnwire.ShortChannelID]wire.OutPoint @@ -134,7 +134,7 @@ func newMockGraph(t *testing.T, numChannels int, g := &mockGraph{ channels: make([]*channeldb.OpenChannel, 0, numChannels), - chanInfos: make(map[wire.OutPoint]*models.ChannelEdgeInfo), + chanInfos: make(map[wire.OutPoint]*models.ChannelEdgeInfo1), chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy1), chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy1), sidToCid: make(map[lnwire.ShortChannelID]wire.OutPoint), @@ -160,7 +160,7 @@ func (g *mockGraph) FetchAllOpenChannels() ([]*channeldb.OpenChannel, error) { } func (g *mockGraph) FetchChannelEdgesByOutpoint( - op *wire.OutPoint) (*models.ChannelEdgeInfo, + op *wire.OutPoint) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { g.mu.Lock() @@ -248,7 +248,7 @@ func (g *mockGraph) addChannel(channel *channeldb.OpenChannel) { } func (g *mockGraph) addEdgePolicy(c *channeldb.OpenChannel, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, pol1, pol2 *models.ChannelEdgePolicy1) { g.mu.Lock() diff --git a/netann/channel_announcement.go b/netann/channel_announcement.go index df4755028..83a8282a6 100644 --- a/netann/channel_announcement.go +++ b/netann/channel_announcement.go @@ -13,7 +13,7 @@ import ( // structs for announcing new channels to other peers, or simply syncing up a // peer's initial routing table upon connect. func CreateChanAnnouncement(chanProof *models.ChannelAuthProof1, - chanInfo *models.ChannelEdgeInfo, + chanInfo *models.ChannelEdgeInfo1, e1, e2 *models.ChannelEdgePolicy1) (*lnwire.ChannelAnnouncement1, *lnwire.ChannelUpdate1, *lnwire.ChannelUpdate1, error) { diff --git a/netann/channel_announcement_test.go b/netann/channel_announcement_test.go index 023a938b4..844a9b1d4 100644 --- a/netann/channel_announcement_test.go +++ b/netann/channel_announcement_test.go @@ -45,7 +45,7 @@ func TestCreateChanAnnouncement(t *testing.T) { BitcoinSig1Bytes: expChanAnn.BitcoinSig1.ToSignatureBytes(), BitcoinSig2Bytes: expChanAnn.BitcoinSig2.ToSignatureBytes(), } - chanInfo := &models.ChannelEdgeInfo{ + chanInfo := &models.ChannelEdgeInfo1{ ChainHash: expChanAnn.ChainHash, ChannelID: expChanAnn.ShortChannelID.ToUint64(), ChannelPoint: wire.OutPoint{Index: 1}, diff --git a/netann/channel_update.go b/netann/channel_update.go index e7d4704b1..8faa34cb2 100644 --- a/netann/channel_update.go +++ b/netann/channel_update.go @@ -84,7 +84,7 @@ func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator // // NOTE: The passed policies can be nil. func ExtractChannelUpdate(ownerPubKey []byte, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, policies ...*models.ChannelEdgePolicy1) ( *lnwire.ChannelUpdate1, error) { @@ -117,7 +117,7 @@ func ExtractChannelUpdate(ownerPubKey []byte, // UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the // given edge info and policy. -func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo, +func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo1, policy *models.ChannelEdgePolicy1) *lnwire.ChannelUpdate1 { return &lnwire.ChannelUpdate1{ @@ -137,7 +137,7 @@ func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo, // ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge // info and policy. -func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo, +func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo1, policy *models.ChannelEdgePolicy1) (*lnwire.ChannelUpdate1, error) { update := UnsignedChannelUpdateFromEdge(info, policy) diff --git a/netann/interface.go b/netann/interface.go index 41acdc954..8fd5eaf27 100644 --- a/netann/interface.go +++ b/netann/interface.go @@ -19,6 +19,6 @@ type DB interface { type ChannelGraph interface { // FetchChannelEdgesByOutpoint returns the channel edge info and most // recent channel edge policies for a given outpoint. - FetchChannelEdgesByOutpoint(*wire.OutPoint) (*models.ChannelEdgeInfo, + FetchChannelEdgesByOutpoint(*wire.OutPoint) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) } diff --git a/routing/blindedpath/blinded_path.go b/routing/blindedpath/blinded_path.go index 09dbb5e6c..3f41b2d7b 100644 --- a/routing/blindedpath/blinded_path.go +++ b/routing/blindedpath/blinded_path.go @@ -42,7 +42,7 @@ type BuildBlindedPathCfg struct { // FetchChannelEdgesByID attempts to look up the two directed edges for // the channel identified by the channel ID. - FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo, + FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // FetchOurOpenChannels fetches this node's set of open channels. diff --git a/routing/blindedpath/blinded_path_test.go b/routing/blindedpath/blinded_path_test.go index 48e1d9de0..d593b034f 100644 --- a/routing/blindedpath/blinded_path_test.go +++ b/routing/blindedpath/blinded_path_test.go @@ -598,7 +598,7 @@ func TestBuildBlindedPath(t *testing.T) { return []*route.Route{realRoute}, nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { return nil, realPolicies[chanID], nil, nil @@ -766,7 +766,7 @@ func TestBuildBlindedPathWithDummyHops(t *testing.T) { return []*route.Route{realRoute}, nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { policy, ok := realPolicies[chanID] @@ -937,7 +937,7 @@ func TestBuildBlindedPathWithDummyHops(t *testing.T) { nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { // Force the call to error for the first 2 channels. diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go index 3a4a1b397..55a9af095 100644 --- a/routing/localchans/manager.go +++ b/routing/localchans/manager.go @@ -32,7 +32,7 @@ type Manager struct { // ForAllOutgoingChannels is required to iterate over all our local // channels. ForAllOutgoingChannels func(cb func(kvdb.RTx, - *models.ChannelEdgeInfo, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1) error) error // FetchChannel is used to query local channel parameters. Optionally an @@ -74,7 +74,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy, // otherwise we'll collect them all. err := r.ForAllOutgoingChannels(func( tx kvdb.RTx, - info *models.ChannelEdgeInfo, + info *models.ChannelEdgeInfo1, edge *models.ChannelEdgePolicy1) error { // If we have a channel filter, and this channel isn't a part diff --git a/routing/localchans/manager_test.go b/routing/localchans/manager_test.go index 0f75c4515..0054396d0 100644 --- a/routing/localchans/manager_test.go +++ b/routing/localchans/manager_test.go @@ -22,7 +22,7 @@ func TestManager(t *testing.T) { t.Parallel() type channel struct { - edgeInfo *models.ChannelEdgeInfo + edgeInfo *models.ChannelEdgeInfo1 } var ( @@ -107,7 +107,7 @@ func TestManager(t *testing.T) { } forAllOutgoingChannels := func(cb func(kvdb.RTx, - *models.ChannelEdgeInfo, + *models.ChannelEdgeInfo1, *models.ChannelEdgePolicy1) error) error { for _, c := range channelSet { @@ -166,7 +166,7 @@ func TestManager(t *testing.T) { newPolicy: newPolicy, channelSet: []channel{ { - edgeInfo: &models.ChannelEdgeInfo{ + edgeInfo: &models.ChannelEdgeInfo1{ Capacity: chanCap, ChannelPoint: chanPointValid, }, @@ -183,7 +183,7 @@ func TestManager(t *testing.T) { newPolicy: newPolicy, channelSet: []channel{ { - edgeInfo: &models.ChannelEdgeInfo{ + edgeInfo: &models.ChannelEdgeInfo1{ Capacity: chanCap, ChannelPoint: chanPointValid, }, @@ -200,7 +200,7 @@ func TestManager(t *testing.T) { newPolicy: newPolicy, channelSet: []channel{ { - edgeInfo: &models.ChannelEdgeInfo{ + edgeInfo: &models.ChannelEdgeInfo1{ Capacity: chanCap, ChannelPoint: chanPointValid, }, @@ -221,7 +221,7 @@ func TestManager(t *testing.T) { newPolicy: noMaxHtlcPolicy, channelSet: []channel{ { - edgeInfo: &models.ChannelEdgeInfo{ + edgeInfo: &models.ChannelEdgeInfo1{ Capacity: chanCap, ChannelPoint: chanPointValid, }, diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 3beaf2b35..8af7dd952 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -337,7 +337,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( // We first insert the existence of the edge between the two // nodes. - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: edge.ChannelID, AuthProof: &testAuthProof, ChannelPoint: fundingPoint, @@ -652,7 +652,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, // We first insert the existence of the edge between the two // nodes. - edgeInfo := models.ChannelEdgeInfo{ + edgeInfo := models.ChannelEdgeInfo1{ ChannelID: channelID, AuthProof: &testAuthProof, ChannelPoint: *fundingPoint, diff --git a/routing/router_test.go b/routing/router_test.go index 4433ab442..0f7528455 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -2727,7 +2727,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { ) require.NoError(t, err, "unable to create channel edge") - edge := &models.ChannelEdgeInfo{ + edge := &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), NodeKey1Bytes: pub1, NodeKey2Bytes: pub2, @@ -2806,7 +2806,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { 10000, 510) require.NoError(t, err, "unable to create channel edge") - edge = &models.ChannelEdgeInfo{ + edge = &models.ChannelEdgeInfo1{ ChannelID: chanID.ToUint64(), AuthProof: nil, } diff --git a/rpcserver.go b/rpcserver.go index afc831237..cdd4a3b4c 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -6220,7 +6220,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context, // Next, for each active channel we know of within the graph, create a // similar response which details both the edge information as well as // the routing policies of th nodes connecting the two edges. - err = graph.ForEachChannel(func(edgeInfo *models.ChannelEdgeInfo, + err = graph.ForEachChannel(func(edgeInfo *models.ChannelEdgeInfo1, c1, c2 *models.ChannelEdgePolicy1) error { // Do not include unannounced channels unless specifically @@ -6293,7 +6293,7 @@ func extractInboundFeeSafe(data lnwire.ExtraOpaqueData) lnwire.Fee { return inboundFee } -func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo, +func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo1, c1, c2 *models.ChannelEdgePolicy1) *lnrpc.ChannelEdge { // Make sure the policies match the node they belong to. c1 should point @@ -6427,7 +6427,7 @@ func (r *rpcServer) GetChanInfo(_ context.Context, graph := r.server.graphDB var ( - edgeInfo *models.ChannelEdgeInfo + edgeInfo *models.ChannelEdgeInfo1 edge1, edge2 *models.ChannelEdgePolicy1 err error ) @@ -6497,7 +6497,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, ) err = graph.ForEachNodeChannel(node.PubKeyBytes, - func(_ kvdb.RTx, edge *models.ChannelEdgeInfo, + func(_ kvdb.RTx, edge *models.ChannelEdgeInfo1, c1, c2 *models.ChannelEdgePolicy1) error { numChannels++ @@ -7156,7 +7156,7 @@ func (r *rpcServer) FeeReport(ctx context.Context, var feeReports []*lnrpc.ChannelFeeReport err = channelGraph.ForEachNodeChannel(selfNode.PubKeyBytes, - func(_ kvdb.RTx, chanInfo *models.ChannelEdgeInfo, + func(_ kvdb.RTx, chanInfo *models.ChannelEdgeInfo1, edgePolicy, _ *models.ChannelEdgePolicy1) error { // Self node should always have policies for its diff --git a/server.go b/server.go index 423050ad9..5203cd6f9 100644 --- a/server.go +++ b/server.go @@ -3229,7 +3229,7 @@ func (s *server) establishPersistentConnections() error { selfPub := s.identityECDH.PubKey().SerializeCompressed() err = s.graphDB.ForEachNodeChannel(sourceNode.PubKeyBytes, func( tx kvdb.RTx, - chanInfo *models.ChannelEdgeInfo, + chanInfo *models.ChannelEdgeInfo1, policy, _ *models.ChannelEdgePolicy1) error { // If the remote party has announced the channel to us, but we