diff --git a/autopilot/graph.go b/autopilot/graph.go index 2ce49c127..d9dd2df18 100644 --- a/autopilot/graph.go +++ b/autopilot/graph.go @@ -91,7 +91,7 @@ func (d *dbNode) Addrs() []net.Addr { 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, - _ *models.ChannelEdgePolicy) error { + _ *models.ChannelEdgePolicy1) error { // Skip channels for which no outgoing edge policy is // available. @@ -246,7 +246,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey, if err := d.db.AddChannelEdge(edge); err != nil { return nil, nil, err } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: chanID.ToUint64(), LastUpdate: time.Now(), @@ -262,7 +262,7 @@ func (d *databaseChannelGraph) addRandChannel(node1, node2 *btcec.PublicKey, if err := d.db.UpdateEdgePolicy(edgePolicy); err != nil { return nil, nil, err } - edgePolicy = &models.ChannelEdgePolicy{ + edgePolicy = &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: chanID.ToUint64(), LastUpdate: time.Now(), diff --git a/channeldb/graph.go b/channeldb/graph.go index ade51aa2c..232b3a727 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -240,7 +240,7 @@ func NewChannelGraph(db kvdb.Backend, rejectCacheSize, chanCacheSize int, } err = g.ForEachChannel(func(info *models.ChannelEdgeInfo, - policy1, policy2 *models.ChannelEdgePolicy) error { + policy1, policy2 *models.ChannelEdgePolicy1) error { g.graphCache.AddChannel(info, policy1, policy2) @@ -266,10 +266,10 @@ type channelMapKey struct { // getChannelMap loads all channel edge policies from the database and stores // them in a map. func (c *ChannelGraph) getChannelMap(edges kvdb.RBucket) ( - map[channelMapKey]*models.ChannelEdgePolicy, error) { + map[channelMapKey]*models.ChannelEdgePolicy1, error) { // Create a map to store all channel edge policies. - channelMap := make(map[channelMapKey]*models.ChannelEdgePolicy) + channelMap := make(map[channelMapKey]*models.ChannelEdgePolicy1) err := kvdb.ForAll(edges, func(k, edgeBytes []byte) error { // Skip embedded buckets. @@ -420,7 +420,7 @@ func (c *ChannelGraph) NewPathFindTx() (kvdb.RTx, error) { // for that particular channel edge routing policy will be passed into the // callback. func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error) error { + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) error) error { return c.db.View(func(tx kvdb.RTx) error { edges := tx.ReadBucket(edgeBucket) @@ -490,7 +490,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx, } dbCallback := func(tx kvdb.RTx, e *models.ChannelEdgeInfo, p1, - p2 *models.ChannelEdgePolicy) error { + p2 *models.ChannelEdgePolicy1) error { var cachedInPolicy *models.CachedEdgePolicy if p2 != nil { @@ -576,8 +576,8 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex, err := c.ForEachNodeChannelTx(tx, node.PubKeyBytes, func(tx kvdb.RTx, e *models.ChannelEdgeInfo, - p1 *models.ChannelEdgePolicy, - p2 *models.ChannelEdgePolicy) error { + p1 *models.ChannelEdgePolicy1, + p2 *models.ChannelEdgePolicy1) error { toNodeCallback := func() route.Vertex { return node.PubKeyBytes @@ -1879,11 +1879,11 @@ type ChannelEdge struct { // Policy1 points to the "first" edge policy of the channel containing // the dynamic information required to properly route through the edge. - Policy1 *models.ChannelEdgePolicy + Policy1 *models.ChannelEdgePolicy1 // Policy2 points to the "second" edge policy of the channel containing // the dynamic information required to properly route through the edge. - Policy2 *models.ChannelEdgePolicy + Policy2 *models.ChannelEdgePolicy1 // Node1 is "node 1" in the channel. This is the node that would have // produced Policy1 if it exists. @@ -2526,7 +2526,7 @@ func (c *ChannelGraph) fetchChanInfos(tx kvdb.RTx, chanIDs []uint64) ( } func delEdgeUpdateIndexEntry(edgesBucket kvdb.RwBucket, chanID uint64, - edge1, edge2 *models.ChannelEdgePolicy) error { + edge1, edge2 *models.ChannelEdgePolicy1) error { // First, we'll fetch the edge update index bucket which currently // stores an entry for the channel we're about to delete. @@ -2672,7 +2672,7 @@ func (c *ChannelGraph) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex, // marked with the correct lagging channel since we received an update from only // one side. func makeZombiePubkeys(info *models.ChannelEdgeInfo, - e1, e2 *models.ChannelEdgePolicy) ([33]byte, [33]byte) { + e1, e2 *models.ChannelEdgePolicy1) ([33]byte, [33]byte) { switch { // If we don't have either edge policy, we'll return both pubkeys so @@ -2697,12 +2697,12 @@ func makeZombiePubkeys(info *models.ChannelEdgeInfo, // UpdateEdgePolicy updates the edge routing policy for a single directed edge // within the database for the referenced channel. The `flags` attribute within -// the ChannelEdgePolicy determines which of the directed edges are being +// the ChannelEdgePolicy1 determines which of the directed edges are being // updated. If the flag is 1, then the first node's information is being // updated, otherwise it's the second node's information. The node ordering is // determined by the lexicographical ordering of the identity public keys of the // nodes on either side of the channel. -func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy, +func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy1, op ...batch.SchedulerOption) error { var ( @@ -2750,7 +2750,7 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy, return c.chanScheduler.Execute(r) } -func (c *ChannelGraph) updateEdgeCache(e *models.ChannelEdgePolicy, +func (c *ChannelGraph) updateEdgeCache(e *models.ChannelEdgePolicy1, isUpdate1 bool) { // If an entry for this channel is found in reject cache, we'll modify @@ -2784,7 +2784,7 @@ func (c *ChannelGraph) updateEdgeCache(e *models.ChannelEdgePolicy, // buckets using an existing database transaction. The returned boolean will be // true if the updated policy belongs to node1, and false if the policy belonged // to node2. -func updateEdgePolicy(tx kvdb.RwTx, edge *models.ChannelEdgePolicy, +func updateEdgePolicy(tx kvdb.RwTx, edge *models.ChannelEdgePolicy1, graphCache *GraphCache) (bool, error) { edges := tx.ReadWriteBucket(edgeBucket) @@ -2979,8 +2979,8 @@ 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.ChannelEdgePolicy, - _ *models.ChannelEdgePolicy) error { + info *models.ChannelEdgeInfo, _ *models.ChannelEdgePolicy1, + _ *models.ChannelEdgePolicy1) error { // If this edge doesn't extend to the source node, we'll // terminate our search as we can now conclude that the node is @@ -3122,8 +3122,8 @@ 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.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error { + cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error { return nodeTraversal(tx, n.pubKeyBytes[:], nil, cb) } @@ -3183,8 +3183,8 @@ 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.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error { + cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error { traversal := func(tx kvdb.RTx) error { edges := tx.ReadBucket(edgeBucket) @@ -3272,8 +3272,8 @@ 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.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error { + cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error { return nodeTraversal(nil, nodePub[:], c.db, cb) } @@ -3293,8 +3293,8 @@ func (c *ChannelGraph) ForEachNodeChannel(nodePub route.Vertex, // traversal. func (c *ChannelGraph) ForEachNodeChannelTx(tx kvdb.RTx, nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error { + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error { return nodeTraversal(tx, nodePub[:], c.db, cb) } @@ -3373,13 +3373,13 @@ 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.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { var ( edgeInfo *models.ChannelEdgeInfo - policy1 *models.ChannelEdgePolicy - policy2 *models.ChannelEdgePolicy + policy1 *models.ChannelEdgePolicy1 + policy2 *models.ChannelEdgePolicy1 ) err := kvdb.View(c.db, func(tx kvdb.RTx) error { @@ -3455,16 +3455,16 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) ( // routing policies for the channel in either direction. // // ErrZombieEdge an be returned if the edge is currently marked as a zombie -// within the database. In this case, the ChannelEdgePolicy's will be nil, and +// within the database. In this case, the ChannelEdgePolicy1's will be nil, and // the ChannelEdgeInfo will only include the public keys of each node. func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { var ( edgeInfo *models.ChannelEdgeInfo - policy1 *models.ChannelEdgePolicy - policy2 *models.ChannelEdgePolicy + policy1 *models.ChannelEdgePolicy1 + policy2 *models.ChannelEdgePolicy1 channelID [8]byte ) @@ -4390,7 +4390,7 @@ func deserializeChanEdgeInfo(r io.Reader) (models.ChannelEdgeInfo, error) { return edgeInfo, nil } -func putChanEdgePolicy(edges kvdb.RwBucket, edge *models.ChannelEdgePolicy, +func putChanEdgePolicy(edges kvdb.RwBucket, edge *models.ChannelEdgePolicy1, from, to []byte) error { var edgeKey [33 + 8]byte @@ -4462,7 +4462,7 @@ func putChanEdgePolicy(edges kvdb.RwBucket, edge *models.ChannelEdgePolicy, } // updateEdgePolicyDisabledIndex is used to update the disabledEdgePolicyIndex -// bucket by either add a new disabled ChannelEdgePolicy or remove an existing +// bucket by either add a new disabled ChannelEdgePolicy1 or remove an existing // one. // The direction represents the direction of the edge and disabled is used for // deciding whether to remove or add an entry to the bucket. @@ -4511,7 +4511,7 @@ func putChanEdgePolicyUnknown(edges kvdb.RwBucket, channelID uint64, } func fetchChanEdgePolicy(edges kvdb.RBucket, chanID []byte, - nodePub []byte) (*models.ChannelEdgePolicy, error) { + nodePub []byte) (*models.ChannelEdgePolicy1, error) { var edgeKey [33 + 8]byte copy(edgeKey[:], nodePub) @@ -4544,7 +4544,7 @@ func fetchChanEdgePolicy(edges kvdb.RBucket, chanID []byte, } func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket, - chanID []byte) (*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, + chanID []byte) (*models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { edgeInfo := edgeIndex.Get(chanID) @@ -4575,7 +4575,7 @@ func fetchChanEdgePolicies(edgeIndex kvdb.RBucket, edges kvdb.RBucket, return edge1, edge2, nil } -func serializeChanEdgePolicy(w io.Writer, edge *models.ChannelEdgePolicy, +func serializeChanEdgePolicy(w io.Writer, edge *models.ChannelEdgePolicy1, to []byte) error { err := wire.WriteVarBytes(w, 0, edge.SigBytes) @@ -4642,7 +4642,7 @@ func serializeChanEdgePolicy(w io.Writer, edge *models.ChannelEdgePolicy, return nil } -func deserializeChanEdgePolicy(r io.Reader) (*models.ChannelEdgePolicy, error) { +func deserializeChanEdgePolicy(r io.Reader) (*models.ChannelEdgePolicy1, error) { // Deserialize the policy. Note that in case an optional field is not // found, both an error and a populated policy object are returned. edge, deserializeErr := deserializeChanEdgePolicyRaw(r) @@ -4655,10 +4655,10 @@ func deserializeChanEdgePolicy(r io.Reader) (*models.ChannelEdgePolicy, error) { return edge, deserializeErr } -func deserializeChanEdgePolicyRaw(r io.Reader) (*models.ChannelEdgePolicy, +func deserializeChanEdgePolicyRaw(r io.Reader) (*models.ChannelEdgePolicy1, error) { - edge := &models.ChannelEdgePolicy{} + edge := &models.ChannelEdgePolicy1{} var err error edge.SigBytes, err = wire.ReadVarBytes(r, 0, 80, "sig") diff --git a/channeldb/graph_cache.go b/channeldb/graph_cache.go index 9bd2a8265..888e2dfa5 100644 --- a/channeldb/graph_cache.go +++ b/channeldb/graph_cache.go @@ -29,8 +29,8 @@ type GraphCacheNode interface { // to the caller. ForEachChannel(kvdb.RTx, func(kvdb.RTx, *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error } // DirectedChannel is a type that stores the channel information as seen from @@ -143,8 +143,8 @@ func (c *GraphCache) AddNode(tx kvdb.RTx, node GraphCacheNode) error { return node.ForEachChannel( tx, func(tx kvdb.RTx, info *models.ChannelEdgeInfo, - outPolicy *models.ChannelEdgePolicy, - inPolicy *models.ChannelEdgePolicy) error { + outPolicy *models.ChannelEdgePolicy1, + inPolicy *models.ChannelEdgePolicy1) error { c.AddChannel(info, outPolicy, inPolicy) @@ -157,8 +157,8 @@ 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 *models.ChannelEdgePolicy, policy2 *models.ChannelEdgePolicy) { +func (c *GraphCache) AddChannel(info *models.ChannelEdgeInfo, policy1, + policy2 *models.ChannelEdgePolicy1) { if info == nil { return @@ -220,7 +220,7 @@ func (c *GraphCache) updateOrAddEdge(node route.Vertex, edge *DirectedChannel) { // of the from and to node is not strictly important. But we assume that a // channel edge was added beforehand so that the directed channel struct already // exists in the cache. -func (c *GraphCache) UpdatePolicy(policy *models.ChannelEdgePolicy, fromNode, +func (c *GraphCache) UpdatePolicy(policy *models.ChannelEdgePolicy1, fromNode, toNode route.Vertex, edge1 bool) { // Extract inbound fee if possible and available. If there is a decoding diff --git a/channeldb/graph_cache_test.go b/channeldb/graph_cache_test.go index f7ed5cee6..e3ba3d67a 100644 --- a/channeldb/graph_cache_test.go +++ b/channeldb/graph_cache_test.go @@ -30,8 +30,8 @@ type node struct { features *lnwire.FeatureVector edgeInfos []*models.ChannelEdgeInfo - outPolicies []*models.ChannelEdgePolicy - inPolicies []*models.ChannelEdgePolicy + outPolicies []*models.ChannelEdgePolicy1 + inPolicies []*models.ChannelEdgePolicy1 } func (n *node) PubKey() route.Vertex { @@ -42,8 +42,8 @@ func (n *node) Features() *lnwire.FeatureVector { } func (n *node) ForEachChannel(tx kvdb.RTx, - cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error { + cb func(kvdb.RTx, *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error { for idx := range n.edgeInfos { err := cb( @@ -71,7 +71,7 @@ func TestGraphCacheAddNode(t *testing.T) { channelFlagA, channelFlagB = 1, 0 } - outPolicy1 := &models.ChannelEdgePolicy{ + outPolicy1 := &models.ChannelEdgePolicy1{ ChannelID: 1000, ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagA), ToNode: nodeB, @@ -80,7 +80,7 @@ func TestGraphCacheAddNode(t *testing.T) { 253, 217, 3, 8, 0, 0, 0, 10, 0, 0, 0, 20, }, } - inPolicy1 := &models.ChannelEdgePolicy{ + inPolicy1 := &models.ChannelEdgePolicy1{ ChannelID: 1000, ChannelFlags: lnwire.ChanUpdateChanFlags(channelFlagB), ToNode: nodeA, @@ -95,8 +95,8 @@ func TestGraphCacheAddNode(t *testing.T) { NodeKey2Bytes: pubKey2, Capacity: 500, }}, - outPolicies: []*models.ChannelEdgePolicy{outPolicy1}, - inPolicies: []*models.ChannelEdgePolicy{inPolicy1}, + outPolicies: []*models.ChannelEdgePolicy1{outPolicy1}, + inPolicies: []*models.ChannelEdgePolicy1{inPolicy1}, } cache := NewGraphCache(10) require.NoError(t, cache.AddNode(nil, node)) @@ -153,7 +153,7 @@ func TestGraphCacheAddNode(t *testing.T) { runTest(pubKey2, pubKey1) } -func assertCachedPolicyEqual(t *testing.T, original *models.ChannelEdgePolicy, +func assertCachedPolicyEqual(t *testing.T, original *models.ChannelEdgePolicy1, cached *models.CachedEdgePolicy) { require.Equal(t, original.ChannelID, cached.ChannelID) diff --git a/channeldb/graph_test.go b/channeldb/graph_test.go index 39168a5ab..30be2db44 100644 --- a/channeldb/graph_test.go +++ b/channeldb/graph_test.go @@ -619,8 +619,8 @@ func assertEdgeInfoEqual(t *testing.T, e1 *models.ChannelEdgeInfo, } func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) { var ( firstNode [33]byte @@ -662,7 +662,7 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) ( copy(edgeInfo.BitcoinKey1Bytes[:], firstNode[:]) copy(edgeInfo.BitcoinKey2Bytes[:], secondNode[:]) - edge1 := &models.ChannelEdgePolicy{ + edge1 := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: chanID, LastUpdate: time.Unix(433453, 0), @@ -676,7 +676,7 @@ func createChannelEdge(db kvdb.Backend, node1, node2 *LightningNode) ( ToNode: secondNode, ExtraOpaqueData: []byte{1, 0}, } - edge2 := &models.ChannelEdgePolicy{ + edge2 := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: chanID, LastUpdate: time.Unix(124234, 0), @@ -899,7 +899,7 @@ func assertNoEdge(t *testing.T, g *ChannelGraph, chanID uint64) { } func assertEdgeWithPolicyInCache(t *testing.T, g *ChannelGraph, - e *models.ChannelEdgeInfo, p *models.ChannelEdgePolicy, policy1 bool) { + e *models.ChannelEdgeInfo, p *models.ChannelEdgePolicy1, policy1 bool) { // Check the internal state first. c1, ok := g.graphCache.nodeChannels[e.NodeKey1Bytes][e.ChannelID] @@ -975,16 +975,16 @@ func assertEdgeWithPolicyInCache(t *testing.T, g *ChannelGraph, } } -func randEdgePolicy(chanID uint64, db kvdb.Backend) *models.ChannelEdgePolicy { +func randEdgePolicy(chanID uint64, db kvdb.Backend) *models.ChannelEdgePolicy1 { update := prand.Int63() return newEdgePolicy(chanID, db, update) } func newEdgePolicy(chanID uint64, db kvdb.Backend, - updateTime int64) *models.ChannelEdgePolicy { + updateTime int64) *models.ChannelEdgePolicy1 { - return &models.ChannelEdgePolicy{ + return &models.ChannelEdgePolicy1{ ChannelID: chanID, LastUpdate: time.Unix(updateTime, 0), MessageFlags: 1, @@ -1042,8 +1042,8 @@ func TestGraphTraversal(t *testing.T) { // again if the map is empty that indicates that all edges have // properly been reached. err = graph.ForEachChannel(func(ei *models.ChannelEdgeInfo, - _ *models.ChannelEdgePolicy, - _ *models.ChannelEdgePolicy) error { + _ *models.ChannelEdgePolicy1, + _ *models.ChannelEdgePolicy1) error { delete(chanIndex, ei.ChannelID) return nil @@ -1057,7 +1057,7 @@ func TestGraphTraversal(t *testing.T) { firstNode, secondNode := nodeList[0], nodeList[1] err = graph.ForEachNodeChannel(firstNode.PubKeyBytes, func(_ kvdb.RTx, _ *models.ChannelEdgeInfo, outEdge, - inEdge *models.ChannelEdgePolicy) error { + inEdge *models.ChannelEdgePolicy1) error { // All channels between first and second node should // have fully (both sides) specified policies. @@ -1138,8 +1138,8 @@ func TestGraphTraversalCacheable(t *testing.T) { err := node.ForEachChannel( tx, func(tx kvdb.RTx, info *models.ChannelEdgeInfo, - policy *models.ChannelEdgePolicy, - policy2 *models.ChannelEdgePolicy) error { //nolint:lll + policy *models.ChannelEdgePolicy1, + policy2 *models.ChannelEdgePolicy1) error { //nolint:lll delete(chanIndex, info.ChannelID) return nil @@ -1322,8 +1322,8 @@ 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, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error { + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error { numChans++ return nil @@ -2439,7 +2439,7 @@ func TestFilterChannelRange(t *testing.T) { var updateTime = time.Unix(0, 0) if rand.Int31n(2) == 0 { updateTime = time.Unix(updateTimeSeed, 0) - err = graph.UpdateEdgePolicy(&models.ChannelEdgePolicy{ + err = graph.UpdateEdgePolicy(&models.ChannelEdgePolicy1{ ToNode: node.PubKeyBytes, ChannelFlags: chanFlags, ChannelID: chanID, @@ -2749,7 +2749,7 @@ func TestIncompleteChannelPolicies(t *testing.T) { calls := 0 err := graph.ForEachNodeChannel(node.PubKeyBytes, func(_ kvdb.RTx, _ *models.ChannelEdgeInfo, outEdge, - inEdge *models.ChannelEdgePolicy) error { + inEdge *models.ChannelEdgePolicy1) error { if !expectedOut && outEdge != nil { t.Fatalf("Expected no outgoing policy") @@ -3342,7 +3342,7 @@ func TestDisabledChannelIDs(t *testing.T) { } } -// TestEdgePolicyMissingMaxHtcl tests that if we find a ChannelEdgePolicy in +// TestEdgePolicyMissingMaxHtcl tests that if we find a ChannelEdgePolicy1 in // the DB that indicates that it should support the htlc_maximum_value_msat // field, but it is not part of the opaque data, then we'll handle it as it is // unknown. It also checks that we are correctly able to overwrite it when we @@ -3609,7 +3609,7 @@ func compareNodes(a, b *LightningNode) error { // compareEdgePolicies is used to compare two ChannelEdgePolices using // compareNodes, so as to exclude comparisons of the Nodes' Features struct. -func compareEdgePolicies(a, b *models.ChannelEdgePolicy) error { +func compareEdgePolicies(a, b *models.ChannelEdgePolicy1) error { if a.ChannelID != b.ChannelID { return fmt.Errorf("ChannelID doesn't match: expected %v, "+ "got %v", a.ChannelID, b.ChannelID) @@ -3701,7 +3701,7 @@ func TestLightningNodeSigVerification(t *testing.T) { // TestComputeFee tests fee calculation based on the outgoing amt. func TestComputeFee(t *testing.T) { var ( - policy = models.ChannelEdgePolicy{ + policy = models.ChannelEdgePolicy1{ FeeBaseMSat: 10000, FeeProportionalMillionths: 30000, } @@ -3829,7 +3829,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) { errTimeout := errors.New("timeout adding batched channel") - updates := []*models.ChannelEdgePolicy{edge1, edge2} + updates := []*models.ChannelEdgePolicy1{edge1, edge2} errChan := make(chan error, len(updates)) @@ -3837,7 +3837,7 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) { var wg sync.WaitGroup for _, update := range updates { wg.Add(1) - go func(update *models.ChannelEdgePolicy) { + go func(update *models.ChannelEdgePolicy1) { defer wg.Done() select { @@ -3887,8 +3887,8 @@ func BenchmarkForEachChannel(b *testing.B) { for _, n := range nodes { cb := func(tx kvdb.RTx, info *models.ChannelEdgeInfo, - policy *models.ChannelEdgePolicy, - policy2 *models.ChannelEdgePolicy) error { //nolint:lll + policy *models.ChannelEdgePolicy1, + policy2 *models.ChannelEdgePolicy1) error { //nolint:lll // We need to do something with // the data here, otherwise the @@ -3939,7 +3939,7 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) { // Because of lexigraphical sorting and the usage of random node keys in // this test, we need to determine which edge belongs to node 1 at // runtime. - var edge1 *models.ChannelEdgePolicy + var edge1 *models.ChannelEdgePolicy1 if e1.ToNode == node2.PubKeyBytes { edge1 = e1 } else { diff --git a/channeldb/models/cached_edge_policy.go b/channeldb/models/cached_edge_policy.go index b770ec1fb..89f9a98a0 100644 --- a/channeldb/models/cached_edge_policy.go +++ b/channeldb/models/cached_edge_policy.go @@ -11,7 +11,7 @@ const ( ) // CachedEdgePolicy is a struct that only caches the information of a -// ChannelEdgePolicy that we actually use for pathfinding and therefore need to +// ChannelEdgePolicy1 that we actually use for pathfinding and therefore need to // store in the cache. type CachedEdgePolicy struct { // ChannelID is the unique channel ID for the channel. The first 3 @@ -72,7 +72,7 @@ func (c *CachedEdgePolicy) ComputeFee( } // NewCachedPolicy turns a full policy into a minimal one that can be cached. -func NewCachedPolicy(policy *ChannelEdgePolicy) *CachedEdgePolicy { +func NewCachedPolicy(policy *ChannelEdgePolicy1) *CachedEdgePolicy { return &CachedEdgePolicy{ ChannelID: policy.ChannelID, MessageFlags: policy.MessageFlags, diff --git a/channeldb/models/channel_edge_info.go b/channeldb/models/channel_edge_info.go index 76905cd8f..24aec1e7a 100644 --- a/channeldb/models/channel_edge_info.go +++ b/channeldb/models/channel_edge_info.go @@ -14,7 +14,7 @@ import ( // unique attributes. Once an authenticated channel announcement has been // processed on the network, then an instance of ChannelEdgeInfo encapsulating // the channels attributes is stored. The other portions relevant to routing -// policy of a channel are stored within a ChannelEdgePolicy for each direction +// policy of a channel are stored within a ChannelEdgePolicy1 for each direction // of the channel. type ChannelEdgeInfo struct { // ChannelID is the unique channel ID for the channel. The first 3 diff --git a/channeldb/models/channel_edge_policy.go b/channeldb/models/channel_edge_policy.go index 322ce3cd0..c4db39d7a 100644 --- a/channeldb/models/channel_edge_policy.go +++ b/channeldb/models/channel_edge_policy.go @@ -7,12 +7,12 @@ import ( "github.com/lightningnetwork/lnd/lnwire" ) -// ChannelEdgePolicy represents a *directed* edge within the channel graph. For +// ChannelEdgePolicy1 represents a *directed* edge within the channel graph. For // each channel in the database, there are two distinct edges: one for each // possible direction of travel along the channel. The edges themselves hold // information concerning fees, and minimum time-lock information which is // utilized during path finding. -type ChannelEdgePolicy struct { +type ChannelEdgePolicy1 struct { // SigBytes is the raw bytes of the signature of the channel edge // policy. We'll only parse these if the caller needs to access the // signature for validation purposes. Do not set SigBytes directly, but @@ -78,7 +78,7 @@ type ChannelEdgePolicy struct { // // NOTE: By having this method to access an attribute, we ensure we only need // to fully deserialize the signature if absolutely necessary. -func (c *ChannelEdgePolicy) Signature() (*ecdsa.Signature, error) { +func (c *ChannelEdgePolicy1) Signature() (*ecdsa.Signature, error) { if c.sig != nil { return c.sig, nil } @@ -95,20 +95,20 @@ func (c *ChannelEdgePolicy) Signature() (*ecdsa.Signature, error) { // SetSigBytes updates the signature and invalidates the cached parsed // signature. -func (c *ChannelEdgePolicy) SetSigBytes(sig []byte) { +func (c *ChannelEdgePolicy1) SetSigBytes(sig []byte) { c.SigBytes = sig c.sig = nil } // IsDisabled determines whether the edge has the disabled bit set. -func (c *ChannelEdgePolicy) IsDisabled() bool { +func (c *ChannelEdgePolicy1) IsDisabled() bool { return c.ChannelFlags.IsDisabled() } // ComputeFee computes the fee to forward an HTLC of `amt` milli-satoshis over // the passed active payment channel. This value is currently computed as // specified in BOLT07, but will likely change in the near future. -func (c *ChannelEdgePolicy) ComputeFee( +func (c *ChannelEdgePolicy1) ComputeFee( amt lnwire.MilliSatoshi) lnwire.MilliSatoshi { return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 0c10152ac..af6ca7935 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -556,7 +556,7 @@ type EdgeWithInfo struct { Info *models.ChannelEdgeInfo // Edge describes the policy in one direction of the channel. - Edge *models.ChannelEdgePolicy + Edge *models.ChannelEdgePolicy1 } // PropagateChanPolicyUpdate signals the AuthenticatedGossiper to perform the @@ -1618,7 +1618,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { // within the prune interval or re-broadcast interval. type updateTuple struct { info *models.ChannelEdgeInfo - edge *models.ChannelEdgePolicy + edge *models.ChannelEdgePolicy1 } var ( @@ -1628,7 +1628,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(now time.Time) error { err := d.cfg.Graph.ForAllOutgoingChannels(func( _ kvdb.RTx, info *models.ChannelEdgeInfo, - edge *models.ChannelEdgePolicy) error { + edge *models.ChannelEdgePolicy1) error { // If there's no auth proof attached to this edge, it means // that it is a private channel not meant to be announced to @@ -2188,7 +2188,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool { // Otherwise, we'll retrieve the correct policy that we // currently have stored within our graph to check if this // message is stale by comparing its timestamp. - var p *models.ChannelEdgePolicy + var p *models.ChannelEdgePolicy1 if msg.ChannelFlags&lnwire.ChanUpdateDirection == 0 { p = p1 } else { @@ -2214,7 +2214,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, - edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1, + edge *models.ChannelEdgePolicy1) (*lnwire.ChannelAnnouncement1, *lnwire.ChannelUpdate1, error) { // Parse the unsigned edge into a channel update. @@ -2304,7 +2304,7 @@ func (d *AuthenticatedGossiper) SyncManager() *SyncManager { // keep-alive update based on the previous channel update processed for the same // direction. func IsKeepAliveUpdate(update *lnwire.ChannelUpdate1, - prev *models.ChannelEdgePolicy) bool { + prev *models.ChannelEdgePolicy1) bool { // Both updates should be from the same direction. if update.ChannelFlags&lnwire.ChanUpdateDirection != @@ -3009,7 +3009,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg, // being updated. var ( pubKey *btcec.PublicKey - edgeToUpdate *models.ChannelEdgePolicy + edgeToUpdate *models.ChannelEdgePolicy1 ) direction := upd.ChannelFlags & lnwire.ChanUpdateDirection switch direction { @@ -3098,7 +3098,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg, // different alias. This might mean that SigBytes is incorrect as it // signs a different SCID than the database SCID, but since there will // only be a difference if AuthProof == nil, this is fine. - update := &models.ChannelEdgePolicy{ + update := &models.ChannelEdgePolicy1{ SigBytes: upd.Signature.ToSignatureBytes(), ChannelID: chanInfo.ChannelID, LastUpdate: timestamp, diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index cf1d12fb1..1aa44591e 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -94,7 +94,7 @@ type mockGraphSource struct { mu sync.Mutex nodes []channeldb.LightningNode infos map[uint64]models.ChannelEdgeInfo - edges map[uint64][]models.ChannelEdgePolicy + edges map[uint64][]models.ChannelEdgePolicy1 zombies map[uint64][][33]byte chansToReject map[uint64]struct{} addEdgeErrCode fn.Option[graph.ErrorCode] @@ -104,7 +104,7 @@ func newMockRouter(height uint32) *mockGraphSource { return &mockGraphSource{ bestHeight: height, infos: make(map[uint64]models.ChannelEdgeInfo), - edges: make(map[uint64][]models.ChannelEdgePolicy), + edges: make(map[uint64][]models.ChannelEdgePolicy1), zombies: make(map[uint64][][33]byte), chansToReject: make(map[uint64]struct{}), } @@ -161,14 +161,14 @@ func (r *mockGraphSource) queueValidationFail(chanID uint64) { r.chansToReject[chanID] = struct{}{} } -func (r *mockGraphSource) UpdateEdge(edge *models.ChannelEdgePolicy, +func (r *mockGraphSource) UpdateEdge(edge *models.ChannelEdgePolicy1, _ ...batch.SchedulerOption) error { r.mu.Lock() defer r.mu.Unlock() if len(r.edges[edge.ChannelID]) == 0 { - r.edges[edge.ChannelID] = make([]models.ChannelEdgePolicy, 2) + r.edges[edge.ChannelID] = make([]models.ChannelEdgePolicy1, 2) } if edge.ChannelFlags&lnwire.ChanUpdateDirection == 0 { @@ -208,7 +208,7 @@ func (r *mockGraphSource) ForEachNode(func(node *channeldb.LightningNode) error) func (r *mockGraphSource) ForAllOutgoingChannels(cb func(tx kvdb.RTx, i *models.ChannelEdgeInfo, - c *models.ChannelEdgePolicy) error) error { + c *models.ChannelEdgePolicy1) error) error { r.mu.Lock() defer r.mu.Unlock() @@ -240,8 +240,8 @@ func (r *mockGraphSource) ForAllOutgoingChannels(cb func(tx kvdb.RTx, func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { r.mu.Lock() defer r.mu.Unlock() @@ -265,13 +265,13 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) ( return &chanInfo, nil, nil, nil } - var edge1 *models.ChannelEdgePolicy - if !reflect.DeepEqual(edges[0], models.ChannelEdgePolicy{}) { + var edge1 *models.ChannelEdgePolicy1 + if !reflect.DeepEqual(edges[0], models.ChannelEdgePolicy1{}) { edge1 = &edges[0] } - var edge2 *models.ChannelEdgePolicy - if !reflect.DeepEqual(edges[1], models.ChannelEdgePolicy{}) { + var edge2 *models.ChannelEdgePolicy1 + if !reflect.DeepEqual(edges[1], models.ChannelEdgePolicy1{}) { edge2 = &edges[1] } @@ -371,12 +371,12 @@ func (r *mockGraphSource) IsStaleEdgePolicy(chanID lnwire.ShortChannelID, switch { case flags&lnwire.ChanUpdateDirection == 0 && - !reflect.DeepEqual(edges[0], models.ChannelEdgePolicy{}): + !reflect.DeepEqual(edges[0], models.ChannelEdgePolicy1{}): return !timestamp.After(edges[0].LastUpdate) case flags&lnwire.ChanUpdateDirection == 1 && - !reflect.DeepEqual(edges[1], models.ChannelEdgePolicy{}): + !reflect.DeepEqual(edges[1], models.ChannelEdgePolicy1{}): return !timestamp.After(edges[1].LastUpdate) @@ -2508,7 +2508,7 @@ func TestReceiveRemoteChannelUpdateFirst(t *testing.T) { t.Fatalf("remote update was not processed") } - // Check that the ChannelEdgePolicy was added to the graph. + // Check that the ChannelEdgePolicy1 was added to the graph. chanInfo, e1, e2, err = ctx.router.GetChannelByID( batch.chanUpdAnn1.ShortChannelID, ) @@ -3484,7 +3484,7 @@ out: err = ctx.router.ForAllOutgoingChannels(func( _ kvdb.RTx, info *models.ChannelEdgeInfo, - edge *models.ChannelEdgePolicy) error { + edge *models.ChannelEdgePolicy1) error { edge.TimeLockDelta = uint16(newTimeLockDelta) edgesToUpdate = append(edgesToUpdate, EdgeWithInfo{ diff --git a/funding/manager.go b/funding/manager.go index 3cd7b0fd6..2b8a94adc 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -534,7 +534,7 @@ type Config struct { // DeleteAliasEdge allows the Manager to delete an alias channel edge // from the graph. It also returns our local to-be-deleted policy. DeleteAliasEdge func(scid lnwire.ShortChannelID) ( - *models.ChannelEdgePolicy, error) + *models.ChannelEdgePolicy1, error) // AliasManager is an implementation of the aliasHandler interface that // abstracts away the handling of many alias functions. @@ -3427,7 +3427,7 @@ func (f *Manager) extractAnnounceParams(c *channeldb.OpenChannel) ( func (f *Manager) addToGraph(completeChan *channeldb.OpenChannel, shortChanID *lnwire.ShortChannelID, peerAlias *lnwire.ShortChannelID, - ourPolicy *models.ChannelEdgePolicy) error { + ourPolicy *models.ChannelEdgePolicy1) error { chanID := lnwire.NewChanIDFromOutPoint(completeChan.FundingOutpoint) @@ -4160,7 +4160,7 @@ func (f *Manager) newChanAnnouncement(localPubKey, remotePubKey *btcec.PublicKey, localFundingKey *keychain.KeyDescriptor, remoteFundingKey *btcec.PublicKey, shortChanID lnwire.ShortChannelID, chanID lnwire.ChannelID, fwdMinHTLC, fwdMaxHTLC lnwire.MilliSatoshi, - ourPolicy *models.ChannelEdgePolicy, + ourPolicy *models.ChannelEdgePolicy1, chanType channeldb.ChannelType) (*chanAnnouncement, error) { chainHash := *f.cfg.Wallet.Cfg.NetParams.GenesisHash diff --git a/funding/manager_test.go b/funding/manager_test.go index 5e978d448..d3a08c167 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -554,7 +554,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, OpenChannelPredicate: chainedAcceptor, NotifyPendingOpenChannelEvent: evt.NotifyPendingOpenChannelEvent, DeleteAliasEdge: func(scid lnwire.ShortChannelID) ( - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgePolicy1, error) { return nil, nil }, diff --git a/graph/builder.go b/graph/builder.go index 850dd1fb0..8d92cb6a3 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -148,7 +148,7 @@ type Builder struct { ntfnClientUpdates chan *topologyClientUpdate // channelEdgeMtx is a mutex we use to make sure we process only one - // ChannelEdgePolicy at a time for a given channelID, to ensure + // ChannelEdgePolicy1 at a time for a given channelID, to ensure // consistency between the various database accesses. channelEdgeMtx *multimutex.Mutex[uint64] @@ -484,7 +484,7 @@ func (b *Builder) syncGraphWithChain() error { // boolean is that of node 2, and the final boolean is true if the channel // is considered a zombie. func (b *Builder) isZombieChannel(e1, - e2 *models.ChannelEdgePolicy) (bool, bool, bool) { + e2 *models.ChannelEdgePolicy1) (bool, bool, bool) { chanExpiry := b.cfg.ChannelPruneExpiry @@ -548,7 +548,7 @@ func (b *Builder) pruneZombieChans() error { // First, we'll collect all the channels which are eligible for garbage // collection due to being zombies. filterPruneChans := func(info *models.ChannelEdgeInfo, - e1, e2 *models.ChannelEdgePolicy) error { + e1, e2 *models.ChannelEdgePolicy1) error { // Exit early in case this channel is already marked to be // pruned @@ -1357,8 +1357,8 @@ func (b *Builder) processUpdate(msg interface{}, "view: %v", err) } - case *models.ChannelEdgePolicy: - log.Debugf("Received ChannelEdgePolicy for channel %v", + case *models.ChannelEdgePolicy1: + log.Debugf("Received ChannelEdgePolicy1 for channel %v", msg.ChannelID) // We make sure to hold the mutex for this channel ID, @@ -1490,7 +1490,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool { return false } - err = b.UpdateEdge(&models.ChannelEdgePolicy{ + err = b.UpdateEdge(&models.ChannelEdgePolicy1{ SigBytes: msg.Signature.ToSignatureBytes(), ChannelID: msg.ShortChannelID.ToUint64(), LastUpdate: time.Unix(int64(msg.Timestamp), 0), @@ -1569,7 +1569,7 @@ func (b *Builder) AddEdge(edge *models.ChannelEdgeInfo, // considered as not fully constructed. // // NOTE: This method is part of the ChannelGraphSource interface. -func (b *Builder) UpdateEdge(update *models.ChannelEdgePolicy, +func (b *Builder) UpdateEdge(update *models.ChannelEdgePolicy1, op ...batch.SchedulerOption) error { rMsg := &routingMsg{ @@ -1611,8 +1611,8 @@ func (b *Builder) SyncedHeight() uint32 { // NOTE: This method is part of the ChannelGraphSource interface. func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) ( *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64()) } @@ -1645,12 +1645,12 @@ func (b *Builder) ForEachNode( // // NOTE: This method is part of the ChannelGraphSource interface. func (b *Builder) ForAllOutgoingChannels(cb func(kvdb.RTx, - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy) error) error { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1) error) error { return b.cfg.Graph.ForEachNodeChannel(b.cfg.SelfNode, func(tx kvdb.RTx, c *models.ChannelEdgeInfo, - e *models.ChannelEdgePolicy, - _ *models.ChannelEdgePolicy) error { + e *models.ChannelEdgePolicy1, + _ *models.ChannelEdgePolicy1) error { if e == nil { return fmt.Errorf("channel from self node " + diff --git a/graph/builder_test.go b/graph/builder_test.go index 650ef62f1..a8b94ee39 100644 --- a/graph/builder_test.go +++ b/graph/builder_test.go @@ -154,7 +154,7 @@ func TestIgnoreChannelEdgePolicyForUnknownChannel(t *testing.T) { BitcoinKey2Bytes: pub2, AuthProof: nil, } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: testTime, @@ -1162,7 +1162,7 @@ func TestIsStaleEdgePolicy(t *testing.T) { } // We'll also add two edge policies, one for each direction. - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: updateTimeStamp, @@ -1176,7 +1176,7 @@ func TestIsStaleEdgePolicy(t *testing.T) { t.Fatalf("unable to update edge policy: %v", err) } - edgePolicy = &models.ChannelEdgePolicy{ + edgePolicy = &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: updateTimeStamp, @@ -1607,7 +1607,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( targetNode = edgeInfo.NodeKey2Bytes } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: lnwire.ChanUpdateMsgFlags( edge.MessageFlags, @@ -1987,7 +1987,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, channelFlags |= lnwire.ChanUpdateDisabled } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, ChannelFlags: channelFlags, @@ -2018,7 +2018,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, } channelFlags |= lnwire.ChanUpdateDirection - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, ChannelFlags: channelFlags, diff --git a/graph/interfaces.go b/graph/interfaces.go index 5f2eb218a..3408b366a 100644 --- a/graph/interfaces.go +++ b/graph/interfaces.go @@ -39,7 +39,7 @@ type ChannelGraphSource interface { // UpdateEdge is used to update edge information, without this message // edge considered as not fully constructed. - UpdateEdge(policy *models.ChannelEdgePolicy, + UpdateEdge(policy *models.ChannelEdgePolicy1, op ...batch.SchedulerOption) error // IsStaleNode returns true if the graph source has a node announcement @@ -71,7 +71,7 @@ type ChannelGraphSource interface { // star-graph. ForAllOutgoingChannels(cb func(tx kvdb.RTx, c *models.ChannelEdgeInfo, - e *models.ChannelEdgePolicy) error) error + e *models.ChannelEdgePolicy1) error) error // CurrentBlockHeight returns the block height from POV of the router // subsystem. @@ -79,8 +79,8 @@ type ChannelGraphSource interface { // GetChannelByID return the channel by the channel id. GetChannelByID(chanID lnwire.ShortChannelID) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) // FetchLightningNode attempts to look up a target node by its identity // public key. channeldb.ErrGraphNodeNotFound is returned if the node @@ -188,11 +188,11 @@ type DB interface { // either direction. // // ErrZombieEdge an be returned if the edge is currently marked as a - // zombie within the database. In this case, the ChannelEdgePolicy's + // 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. FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // AddLightningNode adds a vertex/node to the graph database. If the // node is not in the database from before, this will add a new, @@ -220,13 +220,13 @@ type DB interface { // UpdateEdgePolicy updates the edge routing policy for a single // directed edge within the database for the referenced channel. The - // `flags` attribute within the ChannelEdgePolicy determines which of + // `flags` attribute within the ChannelEdgePolicy1 determines which of // the directed edges are being updated. If the flag is 1, then the // first node's information is being updated, otherwise it's the second // node's information. The node ordering is determined by the // lexicographical ordering of the identity public keys of the nodes on // either side of the channel. - UpdateEdgePolicy(edge *models.ChannelEdgePolicy, + UpdateEdgePolicy(edge *models.ChannelEdgePolicy1, op ...batch.SchedulerOption) error // HasLightningNode determines if the graph has a vertex identified by @@ -259,8 +259,8 @@ type DB interface { // Unknown policies are passed into the callback as nil values. ForEachNodeChannel(nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy) error) error + *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1) error) error // UpdateChannelEdge retrieves and update edge of the graph database. // Method only reserved for updating an edge info after its already been diff --git a/graph/notifications.go b/graph/notifications.go index 14ea3d127..2873a08b3 100644 --- a/graph/notifications.go +++ b/graph/notifications.go @@ -342,7 +342,7 @@ func addToTopologyChange(graph DB, update *TopologyChange, // Any new ChannelUpdateAnnouncements will generate a corresponding // ChannelEdgeUpdate notification. - case *models.ChannelEdgePolicy: + case *models.ChannelEdgePolicy1: // We'll need to fetch the edge's information from the database // in order to get the information concerning which nodes are // being connected. diff --git a/graph/notifications_test.go b/graph/notifications_test.go index c6f4855b6..34bbd5423 100644 --- a/graph/notifications_test.go +++ b/graph/notifications_test.go @@ -99,7 +99,7 @@ func createTestNode(t *testing.T) *channeldb.LightningNode { } func randEdgePolicy(chanID *lnwire.ShortChannelID, - node *channeldb.LightningNode) (*models.ChannelEdgePolicy, error) { + node *channeldb.LightningNode) (*models.ChannelEdgePolicy1, error) { InboundFee := models.InboundFee{ Base: prand.Int31() * -1, @@ -112,7 +112,7 @@ func randEdgePolicy(chanID *lnwire.ShortChannelID, return nil, err } - return &models.ChannelEdgePolicy{ + return &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: chanID.ToUint64(), LastUpdate: time.Unix(int64(prand.Int31()), 0), @@ -507,7 +507,7 @@ func TestEdgeUpdateNotification(t *testing.T) { } assertEdgeCorrect := func(t *testing.T, edgeUpdate *ChannelEdgeUpdate, - edgeAnn *models.ChannelEdgePolicy) { + edgeAnn *models.ChannelEdgePolicy1) { if edgeUpdate.ChanID != edgeAnn.ChannelID { t.Fatalf("channel ID of edge doesn't match: "+ diff --git a/graph/validation_barrier.go b/graph/validation_barrier.go index 98d910d89..513fb28de 100644 --- a/graph/validation_barrier.go +++ b/graph/validation_barrier.go @@ -144,7 +144,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) { // These other types don't have any dependants, so no further // initialization needs to be done beyond just occupying a job slot. - case *models.ChannelEdgePolicy: + case *models.ChannelEdgePolicy1: return case *lnwire.ChannelUpdate1: return @@ -188,11 +188,11 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error { switch msg := job.(type) { // Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the // completion of any active ChannelAnnouncement jobs related to them. - case *models.ChannelEdgePolicy: + case *models.ChannelEdgePolicy1: shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) signals, ok = v.chanEdgeDependencies[shortID] - jobDesc = fmt.Sprintf("job=lnwire.ChannelEdgePolicy, scid=%v", + jobDesc = fmt.Sprintf("job=lnwire.ChannelEdgePolicy1, scid=%v", msg.ChannelID) case *channeldb.LightningNode: @@ -297,7 +297,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) { delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID)) case *lnwire.ChannelUpdate1: delete(v.chanEdgeDependencies, msg.ShortChannelID) - case *models.ChannelEdgePolicy: + case *models.ChannelEdgePolicy1: shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) delete(v.chanEdgeDependencies, shortID) diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index 662c0d08d..07c242316 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -289,8 +289,8 @@ func (s *Server) ImportGraph(ctx context.Context, rpcEdge.ChanPoint, err) } - makePolicy := func(rpcPolicy *lnrpc.RoutingPolicy) *models.ChannelEdgePolicy { //nolint:lll - policy := &models.ChannelEdgePolicy{ + makePolicy := func(rpcPolicy *lnrpc.RoutingPolicy) *models.ChannelEdgePolicy1 { //nolint:lll + policy := &models.ChannelEdgePolicy1{ ChannelID: rpcEdge.ChannelId, LastUpdate: time.Unix( int64(rpcPolicy.LastUpdate), 0, diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go index dcb1bef71..cb8cb82e2 100644 --- a/lnrpc/invoicesrpc/addinvoice.go +++ b/lnrpc/invoicesrpc/addinvoice.go @@ -624,7 +624,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig, // chanCanBeHopHint returns true if the target channel is eligible to be a hop // hint. func chanCanBeHopHint(channel *HopHintInfo, cfg *SelectHopHintsCfg) ( - *models.ChannelEdgePolicy, bool) { + *models.ChannelEdgePolicy1, bool) { // Since we're only interested in our private channels, we'll skip // public ones. @@ -679,7 +679,7 @@ func chanCanBeHopHint(channel *HopHintInfo, cfg *SelectHopHintsCfg) ( // Now, we'll need to determine which is the correct policy for HTLCs // being sent from the remote node. - var remotePolicy *models.ChannelEdgePolicy + var remotePolicy *models.ChannelEdgePolicy1 if bytes.Equal(remotePub[:], info.NodeKey1Bytes[:]) { remotePolicy = p1 } else { @@ -737,9 +737,9 @@ func newHopHintInfo(c *channeldb.OpenChannel, isActive bool) *HopHintInfo { } // newHopHint returns a new hop hint using the relevant data from a hopHintInfo -// and a ChannelEdgePolicy. +// and a ChannelEdgePolicy1. func newHopHint(hopHintInfo *HopHintInfo, - chanPolicy *models.ChannelEdgePolicy) zpay32.HopHint { + chanPolicy *models.ChannelEdgePolicy1) zpay32.HopHint { return zpay32.HopHint{ NodeID: hopHintInfo.RemotePubkey, @@ -763,7 +763,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, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // GetAlias allows the peer's alias SCID to be retrieved for private diff --git a/lnrpc/invoicesrpc/addinvoice_test.go b/lnrpc/invoicesrpc/addinvoice_test.go index 76a529f8c..5d4fd7e0d 100644 --- a/lnrpc/invoicesrpc/addinvoice_test.go +++ b/lnrpc/invoicesrpc/addinvoice_test.go @@ -67,8 +67,8 @@ 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.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { args := h.Mock.Called(chanID) @@ -83,10 +83,10 @@ func (h *hopHintsConfigMock) FetchChannelEdgesByID(chanID uint64) ( edgeInfo, ok := args.Get(0).(*models.ChannelEdgeInfo) require.True(h.t, ok) - policy1, ok := args.Get(1).(*models.ChannelEdgePolicy) + policy1, ok := args.Get(1).(*models.ChannelEdgePolicy1) require.True(h.t, ok) - policy2, ok := args.Get(2).(*models.ChannelEdgePolicy) + policy2, ok := args.Get(2).(*models.ChannelEdgePolicy1) require.True(h.t, ok) return edgeInfo, policy1, policy2, err @@ -227,8 +227,8 @@ var shouldIncludeChannelTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) h.Mock.On( @@ -265,8 +265,8 @@ var shouldIncludeChannelTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) alias := lnwire.ShortChannelID{TxPosition: 5} h.Mock.On( @@ -308,12 +308,12 @@ var shouldIncludeChannelTestCases = []struct { &models.ChannelEdgeInfo{ NodeKey1Bytes: selectedPolicy, }, - &models.ChannelEdgePolicy{ + &models.ChannelEdgePolicy1{ FeeBaseMSat: 1000, FeeProportionalMillionths: 20, TimeLockDelta: 13, }, - &models.ChannelEdgePolicy{}, + &models.ChannelEdgePolicy1{}, nil, ) }, @@ -354,8 +354,8 @@ var shouldIncludeChannelTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{ + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{ FeeBaseMSat: 1000, FeeProportionalMillionths: 20, TimeLockDelta: 13, @@ -399,8 +399,8 @@ var shouldIncludeChannelTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{ + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{ FeeBaseMSat: 1000, FeeProportionalMillionths: 20, TimeLockDelta: 13, @@ -566,8 +566,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 1, @@ -616,8 +616,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 10, @@ -667,8 +667,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 1, @@ -700,8 +700,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) // Prepare the mock for the second channel. @@ -717,8 +717,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 10, @@ -754,8 +754,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) // Prepare the mock for the second channel. @@ -771,8 +771,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 10, @@ -809,8 +809,8 @@ var populateHopHintsTestCases = []struct { "FetchChannelEdgesByID", mock.Anything, ).Once().Return( &models.ChannelEdgeInfo{}, - &models.ChannelEdgePolicy{}, - &models.ChannelEdgePolicy{}, nil, + &models.ChannelEdgePolicy1{}, + &models.ChannelEdgePolicy1{}, nil, ) }, maxHopHints: 1, diff --git a/netann/chan_status_manager_test.go b/netann/chan_status_manager_test.go index c709a95f2..46e1939fe 100644 --- a/netann/chan_status_manager_test.go +++ b/netann/chan_status_manager_test.go @@ -67,7 +67,7 @@ func createChannel(t *testing.T) *channeldb.OpenChannel { // 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, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy) { + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1) { var ( pubkey1 [33]byte @@ -104,13 +104,13 @@ func createEdgePolicies(t *testing.T, channel *channeldb.OpenChannel, NodeKey1Bytes: pubkey1, NodeKey2Bytes: pubkey2, }, - &models.ChannelEdgePolicy{ + &models.ChannelEdgePolicy1{ ChannelID: channel.ShortChanID().ToUint64(), ChannelFlags: dir1, LastUpdate: time.Now(), SigBytes: testSigBytes, }, - &models.ChannelEdgePolicy{ + &models.ChannelEdgePolicy1{ ChannelID: channel.ShortChanID().ToUint64(), ChannelFlags: dir2, LastUpdate: time.Now(), @@ -122,8 +122,8 @@ type mockGraph struct { mu sync.Mutex channels []*channeldb.OpenChannel chanInfos map[wire.OutPoint]*models.ChannelEdgeInfo - chanPols1 map[wire.OutPoint]*models.ChannelEdgePolicy - chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy + chanPols1 map[wire.OutPoint]*models.ChannelEdgePolicy1 + chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy1 sidToCid map[lnwire.ShortChannelID]wire.OutPoint updates chan *lnwire.ChannelUpdate1 @@ -135,8 +135,8 @@ func newMockGraph(t *testing.T, numChannels int, g := &mockGraph{ channels: make([]*channeldb.OpenChannel, 0, numChannels), chanInfos: make(map[wire.OutPoint]*models.ChannelEdgeInfo), - chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy), - chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy), + chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy1), + chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy1), sidToCid: make(map[lnwire.ShortChannelID]wire.OutPoint), updates: make(chan *lnwire.ChannelUpdate1, 2*numChannels), } @@ -161,7 +161,7 @@ func (g *mockGraph) FetchAllOpenChannels() ([]*channeldb.OpenChannel, error) { func (g *mockGraph) FetchChannelEdgesByOutpoint( op *wire.OutPoint) (*models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) { + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) { g.mu.Lock() defer g.mu.Unlock() @@ -210,7 +210,7 @@ func (g *mockGraph) ApplyChannelUpdate(update *lnwire.ChannelUpdate1, timestamp := time.Unix(int64(update.Timestamp), 0) - policy := &models.ChannelEdgePolicy{ + policy := &models.ChannelEdgePolicy1{ ChannelID: update.ShortChannelID.ToUint64(), ChannelFlags: update.ChannelFlags, LastUpdate: timestamp, @@ -249,7 +249,7 @@ func (g *mockGraph) addChannel(channel *channeldb.OpenChannel) { func (g *mockGraph) addEdgePolicy(c *channeldb.OpenChannel, info *models.ChannelEdgeInfo, - pol1, pol2 *models.ChannelEdgePolicy) { + pol1, pol2 *models.ChannelEdgePolicy1) { g.mu.Lock() defer g.mu.Unlock() diff --git a/netann/channel_announcement.go b/netann/channel_announcement.go index 27732e982..df4755028 100644 --- a/netann/channel_announcement.go +++ b/netann/channel_announcement.go @@ -14,7 +14,7 @@ import ( // peer's initial routing table upon connect. func CreateChanAnnouncement(chanProof *models.ChannelAuthProof1, chanInfo *models.ChannelEdgeInfo, - e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1, + e1, e2 *models.ChannelEdgePolicy1) (*lnwire.ChannelAnnouncement1, *lnwire.ChannelUpdate1, *lnwire.ChannelUpdate1, error) { // First, using the parameters of the channel, along with the channel diff --git a/netann/channel_update.go b/netann/channel_update.go index c8992ccc6..e7d4704b1 100644 --- a/netann/channel_update.go +++ b/netann/channel_update.go @@ -85,11 +85,11 @@ func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator // NOTE: The passed policies can be nil. func ExtractChannelUpdate(ownerPubKey []byte, info *models.ChannelEdgeInfo, - policies ...*models.ChannelEdgePolicy) ( + policies ...*models.ChannelEdgePolicy1) ( *lnwire.ChannelUpdate1, error) { // Helper function to extract the owner of the given policy. - owner := func(edge *models.ChannelEdgePolicy) []byte { + owner := func(edge *models.ChannelEdgePolicy1) []byte { var pubKey *btcec.PublicKey if edge.ChannelFlags&lnwire.ChanUpdateDirection == 0 { pubKey, _ = info.NodeKey1() @@ -118,7 +118,7 @@ func ExtractChannelUpdate(ownerPubKey []byte, // UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the // given edge info and policy. func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo, - policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate1 { + policy *models.ChannelEdgePolicy1) *lnwire.ChannelUpdate1 { return &lnwire.ChannelUpdate1{ ChainHash: info.ChainHash, @@ -138,7 +138,7 @@ func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo, // ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge // info and policy. func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo, - policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate1, error) { + policy *models.ChannelEdgePolicy1) (*lnwire.ChannelUpdate1, error) { update := UnsignedChannelUpdateFromEdge(info, policy) diff --git a/netann/interface.go b/netann/interface.go index d6cdb46d0..41acdc954 100644 --- a/netann/interface.go +++ b/netann/interface.go @@ -20,5 +20,5 @@ type ChannelGraph interface { // FetchChannelEdgesByOutpoint returns the channel edge info and most // recent channel edge policies for a given outpoint. FetchChannelEdgesByOutpoint(*wire.OutPoint) (*models.ChannelEdgeInfo, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) } diff --git a/peer/brontide.go b/peer/brontide.go index 55f36b2f9..f8d5f0f5d 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -1035,7 +1035,7 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) ( // // TODO(roasbeef): can add helper method to get policy for // particular channel. - var selfPolicy *models.ChannelEdgePolicy + var selfPolicy *models.ChannelEdgePolicy1 if info != nil && bytes.Equal(info.NodeKey1Bytes[:], p.cfg.ServerPubKey[:]) { diff --git a/routing/blindedpath/blinded_path.go b/routing/blindedpath/blinded_path.go index bc14daa40..09dbb5e6c 100644 --- a/routing/blindedpath/blinded_path.go +++ b/routing/blindedpath/blinded_path.go @@ -43,7 +43,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, - *models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error) + *models.ChannelEdgePolicy1, *models.ChannelEdgePolicy1, error) // FetchOurOpenChannels fetches this node's set of open channels. FetchOurOpenChannels func() ([]*channeldb.OpenChannel, error) @@ -652,7 +652,7 @@ func getNodeChannelPolicy(cfg *BuildBlindedPathCfg, chanID uint64, // node in question. We know the update is the correct one if the // "ToNode" for the fetched policy is _not_ equal to the node ID in // question. - var policy *models.ChannelEdgePolicy + var policy *models.ChannelEdgePolicy1 switch { case update1 != nil && !bytes.Equal(update1.ToNode[:], nodeID[:]): policy = update1 diff --git a/routing/blindedpath/blinded_path_test.go b/routing/blindedpath/blinded_path_test.go index 51d028eaf..48e1d9de0 100644 --- a/routing/blindedpath/blinded_path_test.go +++ b/routing/blindedpath/blinded_path_test.go @@ -580,7 +580,7 @@ func TestBuildBlindedPath(t *testing.T) { }, } - realPolicies := map[uint64]*models.ChannelEdgePolicy{ + realPolicies := map[uint64]*models.ChannelEdgePolicy1{ chanCB: { ChannelID: chanCB, ToNode: bob, @@ -598,8 +598,8 @@ func TestBuildBlindedPath(t *testing.T) { return []*route.Route{realRoute}, nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { return nil, realPolicies[chanID], nil, nil }, @@ -748,7 +748,7 @@ func TestBuildBlindedPathWithDummyHops(t *testing.T) { }, } - realPolicies := map[uint64]*models.ChannelEdgePolicy{ + realPolicies := map[uint64]*models.ChannelEdgePolicy1{ chanCB: { ChannelID: chanCB, ToNode: bob, @@ -766,8 +766,8 @@ func TestBuildBlindedPathWithDummyHops(t *testing.T) { return []*route.Route{realRoute}, nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { policy, ok := realPolicies[chanID] if !ok { @@ -937,8 +937,8 @@ func TestBuildBlindedPathWithDummyHops(t *testing.T) { nil }, FetchChannelEdgesByID: func(chanID uint64) ( - *models.ChannelEdgeInfo, *models.ChannelEdgePolicy, - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgeInfo, *models.ChannelEdgePolicy1, + *models.ChannelEdgePolicy1, error) { // Force the call to error for the first 2 channels. if errCount < 2 { diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go index f0f9b88de..3a4a1b397 100644 --- a/routing/localchans/manager.go +++ b/routing/localchans/manager.go @@ -33,7 +33,7 @@ type Manager struct { // channels. ForAllOutgoingChannels func(cb func(kvdb.RTx, *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy) error) error + *models.ChannelEdgePolicy1) error) error // FetchChannel is used to query local channel parameters. Optionally an // existing db tx can be supplied. @@ -75,7 +75,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy, err := r.ForAllOutgoingChannels(func( tx kvdb.RTx, info *models.ChannelEdgeInfo, - edge *models.ChannelEdgePolicy) error { + edge *models.ChannelEdgePolicy1) error { // If we have a channel filter, and this channel isn't a part // of it, then we'll skip it. @@ -182,7 +182,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy, // updateEdge updates the given edge with the new schema. func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint, - edge *models.ChannelEdgePolicy, + edge *models.ChannelEdgePolicy1, newSchema routing.ChannelPolicy) error { // Update forwarding fee scheme and required time lock delta. diff --git a/routing/localchans/manager_test.go b/routing/localchans/manager_test.go index 7594eef04..0f75c4515 100644 --- a/routing/localchans/manager_test.go +++ b/routing/localchans/manager_test.go @@ -44,7 +44,7 @@ func TestManager(t *testing.T) { MaxHTLC: 5000, } - currentPolicy := models.ChannelEdgePolicy{ + currentPolicy := models.ChannelEdgePolicy1{ MinHTLC: minHTLC, MessageFlags: lnwire.ChanUpdateRequiredMaxHtlc, } @@ -108,7 +108,7 @@ func TestManager(t *testing.T) { forAllOutgoingChannels := func(cb func(kvdb.RTx, *models.ChannelEdgeInfo, - *models.ChannelEdgePolicy) error) error { + *models.ChannelEdgePolicy1) error) error { for _, c := range channelSet { if err := cb(nil, c.edgeInfo, ¤tPolicy); err != nil { @@ -152,7 +152,7 @@ func TestManager(t *testing.T) { tests := []struct { name string - currentPolicy models.ChannelEdgePolicy + currentPolicy models.ChannelEdgePolicy1 newPolicy routing.ChannelPolicy channelSet []channel specifiedChanPoints []wire.OutPoint diff --git a/routing/pathfind.go b/routing/pathfind.go index 01325c223..a415bb996 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -87,7 +87,7 @@ var ( ) // edgePolicyWithSource is a helper struct to keep track of the source node -// of a channel edge. ChannelEdgePolicy only contains to destination node +// of a channel edge. ChannelEdgePolicy1 only contains to destination node // of the edge. type edgePolicyWithSource struct { sourceNode route.Vertex @@ -1127,7 +1127,7 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, // destination features were provided. This is fine though, since our // route construction does not care where the features are actually // taken from. In the future we may wish to do route construction within - // findPath, and avoid using ChannelEdgePolicy altogether. + // findPath, and avoid using ChannelEdgePolicy1 altogether. pathEdges[len(pathEdges)-1].policy.ToNodeFeatures = features log.Debugf("Found route: probability=%v, hops=%v, fee=%v", diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 6f8a5784c..3beaf2b35 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -368,7 +368,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) ( targetNode = edgeInfo.NodeKey2Bytes } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: lnwire.ChanUpdateMsgFlags(edge.MessageFlags), ChannelFlags: channelFlags, @@ -692,7 +692,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, channelFlags |= lnwire.ChanUpdateDisabled } - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, ChannelFlags: channelFlags, @@ -722,7 +722,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool, } channelFlags |= lnwire.ChanUpdateDirection - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), MessageFlags: msgFlags, ChannelFlags: channelFlags, diff --git a/routing/router_test.go b/routing/router_test.go index 05fe53786..4433ab442 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -2739,7 +2739,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { // We must add the edge policy to be able to use the edge for route // finding. - edgePolicy := &models.ChannelEdgePolicy{ + edgePolicy := &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: testTime, @@ -2754,7 +2754,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { require.NoError(t, ctx.graph.UpdateEdgePolicy(edgePolicy)) // Create edge in the other direction as well. - edgePolicy = &models.ChannelEdgePolicy{ + edgePolicy = &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: testTime, @@ -2817,7 +2817,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { require.NoError(t, ctx.graph.AddChannelEdge(edge)) - edgePolicy = &models.ChannelEdgePolicy{ + edgePolicy = &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: testTime, @@ -2831,7 +2831,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) { require.NoError(t, ctx.graph.UpdateEdgePolicy(edgePolicy)) - edgePolicy = &models.ChannelEdgePolicy{ + edgePolicy = &models.ChannelEdgePolicy1{ SigBytes: testSig.Serialize(), ChannelID: edge.ChannelID, LastUpdate: testTime, @@ -2928,12 +2928,12 @@ func createDummyLightningPayment(t *testing.T, type mockGraphBuilder struct { rejectUpdate bool - updateEdge func(update *models.ChannelEdgePolicy) error + updateEdge func(update *models.ChannelEdgePolicy1) error } func newMockGraphBuilder(graph graph.DB) *mockGraphBuilder { return &mockGraphBuilder{ - updateEdge: func(update *models.ChannelEdgePolicy) error { + updateEdge: func(update *models.ChannelEdgePolicy1) error { return graph.UpdateEdgePolicy(update) }, } @@ -2948,7 +2948,7 @@ func (m *mockGraphBuilder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool { return false } - err := m.updateEdge(&models.ChannelEdgePolicy{ + err := m.updateEdge(&models.ChannelEdgePolicy1{ SigBytes: msg.Signature.ToSignatureBytes(), ChannelID: msg.ShortChannelID.ToUint64(), LastUpdate: time.Unix(int64(msg.Timestamp), 0), diff --git a/rpcserver.go b/rpcserver.go index cd2198e28..afc831237 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -6221,7 +6221,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context, // 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, - c1, c2 *models.ChannelEdgePolicy) error { + c1, c2 *models.ChannelEdgePolicy1) error { // Do not include unannounced channels unless specifically // requested. Unannounced channels include both private channels as @@ -6294,7 +6294,7 @@ func extractInboundFeeSafe(data lnwire.ExtraOpaqueData) lnwire.Fee { } func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo, - c1, c2 *models.ChannelEdgePolicy) *lnrpc.ChannelEdge { + c1, c2 *models.ChannelEdgePolicy1) *lnrpc.ChannelEdge { // Make sure the policies match the node they belong to. c1 should point // to the policy for NodeKey1, and c2 for NodeKey2. @@ -6337,7 +6337,7 @@ func marshalDBEdge(edgeInfo *models.ChannelEdgeInfo, } func marshalDBRoutingPolicy( - policy *models.ChannelEdgePolicy) *lnrpc.RoutingPolicy { + policy *models.ChannelEdgePolicy1) *lnrpc.RoutingPolicy { disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0 @@ -6428,7 +6428,7 @@ func (r *rpcServer) GetChanInfo(_ context.Context, var ( edgeInfo *models.ChannelEdgeInfo - edge1, edge2 *models.ChannelEdgePolicy + edge1, edge2 *models.ChannelEdgePolicy1 err error ) @@ -6498,7 +6498,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context, err = graph.ForEachNodeChannel(node.PubKeyBytes, func(_ kvdb.RTx, edge *models.ChannelEdgeInfo, - c1, c2 *models.ChannelEdgePolicy) error { + c1, c2 *models.ChannelEdgePolicy1) error { numChannels++ totalCapacity += edge.Capacity @@ -7157,7 +7157,7 @@ func (r *rpcServer) FeeReport(ctx context.Context, var feeReports []*lnrpc.ChannelFeeReport err = channelGraph.ForEachNodeChannel(selfNode.PubKeyBytes, func(_ kvdb.RTx, chanInfo *models.ChannelEdgeInfo, - edgePolicy, _ *models.ChannelEdgePolicy) error { + edgePolicy, _ *models.ChannelEdgePolicy1) error { // Self node should always have policies for its // channels. diff --git a/server.go b/server.go index 9de3f9135..423050ad9 100644 --- a/server.go +++ b/server.go @@ -1290,7 +1290,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, // Wrap the DeleteChannelEdges method so that the funding manager can // use it without depending on several layers of indirection. deleteAliasEdge := func(scid lnwire.ShortChannelID) ( - *models.ChannelEdgePolicy, error) { + *models.ChannelEdgePolicy1, error) { info, e1, e2, err := s.graphDB.FetchChannelEdgesByID( scid.ToUint64(), @@ -1309,7 +1309,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, var ourKey [33]byte copy(ourKey[:], nodeKeyDesc.PubKey.SerializeCompressed()) - var ourPolicy *models.ChannelEdgePolicy + var ourPolicy *models.ChannelEdgePolicy1 if info != nil && info.NodeKey1Bytes == ourKey { ourPolicy = e1 } else { @@ -3230,7 +3230,7 @@ func (s *server) establishPersistentConnections() error { err = s.graphDB.ForEachNodeChannel(sourceNode.PubKeyBytes, func( tx kvdb.RTx, chanInfo *models.ChannelEdgeInfo, - policy, _ *models.ChannelEdgePolicy) error { + policy, _ *models.ChannelEdgePolicy1) error { // If the remote party has announced the channel to us, but we // haven't yet, then we won't have a policy. However, we don't