graph/db: thread context through FetchChannelEdgesByID
This commit is contained in:
14 files changed
+93
-42
No files matched your search
@@ -354,7 +354,7 @@ func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
|
|||||||
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
|
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
|
||||||
|
|
||||||
chanInfo, e1, e2, err := c.graph.FetchChannelEdgesByID(
|
chanInfo, e1, e2, err := c.graph.FetchChannelEdgesByID(
|
||||||
shortChanID.ToUint64(),
|
context.TODO(), shortChanID.ToUint64(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+3
-1
@@ -1259,7 +1259,9 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) (
|
|||||||
*models.ChannelEdgePolicy,
|
*models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
|
return b.cfg.Graph.FetchChannelEdgesByID(
|
||||||
|
context.TODO(), chanID.ToUint64(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchNode attempts to look up a target node by its identity public
|
// FetchNode attempts to look up a target node by its identity public
|
||||||
|
|||||||
+6
-4
@@ -739,12 +739,13 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID.
|
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID.
|
||||||
func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64) (
|
func (c *ChannelGraph) FetchChannelEdgesByID(ctx context.Context,
|
||||||
|
chanID uint64) (
|
||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
return c.db.FetchChannelEdgesByID(
|
return c.db.FetchChannelEdgesByID(
|
||||||
lnwire.GossipVersion1, chanID,
|
ctx, lnwire.GossipVersion1, chanID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,11 +813,12 @@ func (c *VersionedGraph) FetchNode(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID.
|
// FetchChannelEdgesByID attempts to lookup directed edges by channel ID.
|
||||||
func (c *VersionedGraph) FetchChannelEdgesByID(chanID uint64) (
|
func (c *VersionedGraph) FetchChannelEdgesByID(ctx context.Context,
|
||||||
|
chanID uint64) (
|
||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
return c.db.FetchChannelEdgesByID(c.v, chanID)
|
return c.db.FetchChannelEdgesByID(ctx, c.v, chanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
|
// FetchChannelEdgesByOutpoint attempts to lookup directed edges by funding
|
||||||
|
|||||||
+20
-8
@@ -643,7 +643,7 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
|
|
||||||
// Ensure that both policies are returned as unknown (nil) and that
|
// Ensure that both policies are returned as unknown (nil) and that
|
||||||
// the edge info round-trips correctly.
|
// the edge info round-trips correctly.
|
||||||
dbEdge, e1, e2, err := graph.FetchChannelEdgesByID(chanID)
|
dbEdge, e1, e2, err := graph.FetchChannelEdgesByID(ctx, chanID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Nil(t, e1)
|
require.Nil(t, e1)
|
||||||
require.Nil(t, e2)
|
require.Nil(t, e2)
|
||||||
@@ -712,7 +712,7 @@ func testEdgeInsertionDeletion(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
// Assert that if the edge is a zombie, then FetchChannelEdgesByID
|
// Assert that if the edge is a zombie, then FetchChannelEdgesByID
|
||||||
// still returns a populated models.ChannelEdgeInfo as its comment
|
// still returns a populated models.ChannelEdgeInfo as its comment
|
||||||
// description promises.
|
// description promises.
|
||||||
edge, _, _, err := graph.FetchChannelEdgesByID(chanID)
|
edge, _, _, err := graph.FetchChannelEdgesByID(ctx, chanID)
|
||||||
require.ErrorIs(t, err, ErrZombieEdge)
|
require.ErrorIs(t, err, ErrZombieEdge)
|
||||||
require.NotNil(t, edge)
|
require.NotNil(t, edge)
|
||||||
|
|
||||||
@@ -1195,7 +1195,9 @@ func testEdgeInfoUpdates(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
|
|
||||||
// With the edges inserted, perform some queries to ensure that they've
|
// With the edges inserted, perform some queries to ensure that they've
|
||||||
// been inserted properly.
|
// been inserted properly.
|
||||||
dbEdgeInfo, dbEdge1, dbEdge2, err := graph.FetchChannelEdgesByID(chanID)
|
dbEdgeInfo, dbEdge1, dbEdge2, err := graph.FetchChannelEdgesByID(
|
||||||
|
ctx, chanID,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch channel by ID")
|
require.NoError(t, err, "unable to fetch channel by ID")
|
||||||
compareEdgePolicies(t, dbEdge1, edge1)
|
compareEdgePolicies(t, dbEdge1, edge1)
|
||||||
compareEdgePolicies(t, dbEdge2, edge2)
|
compareEdgePolicies(t, dbEdge2, edge2)
|
||||||
@@ -1578,7 +1580,9 @@ func testAddEdgeProof(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
require.NoError(t, graph.AddChannelEdge(ctx, edge1))
|
require.NoError(t, graph.AddChannelEdge(ctx, edge1))
|
||||||
|
|
||||||
// Fetch the edge and assert that the proof is nil.
|
// Fetch the edge and assert that the proof is nil.
|
||||||
dbEdge, _, _, err := graph.FetchChannelEdgesByID(edge1.ChannelID)
|
dbEdge, _, _, err := graph.FetchChannelEdgesByID(
|
||||||
|
ctx, edge1.ChannelID,
|
||||||
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Nil(t, dbEdge.AuthProof)
|
require.Nil(t, dbEdge.AuthProof)
|
||||||
|
|
||||||
@@ -1608,7 +1612,9 @@ func testAddEdgeProof(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
require.NoError(t, graph.AddEdgeProof(scid1, proof))
|
require.NoError(t, graph.AddEdgeProof(scid1, proof))
|
||||||
|
|
||||||
// Fetch the edge again and assert that the proof is now set.
|
// Fetch the edge again and assert that the proof is now set.
|
||||||
dbEdge, _, _, err = graph.FetchChannelEdgesByID(edge1.ChannelID)
|
dbEdge, _, _, err = graph.FetchChannelEdgesByID(
|
||||||
|
ctx, edge1.ChannelID,
|
||||||
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, dbEdge.AuthProof)
|
require.NotNil(t, dbEdge.AuthProof)
|
||||||
|
|
||||||
@@ -1618,7 +1624,9 @@ func testAddEdgeProof(t *testing.T, v lnwire.GossipVersion) {
|
|||||||
require.NoError(t, graph.AddChannelEdge(ctx, edge2))
|
require.NoError(t, graph.AddChannelEdge(ctx, edge2))
|
||||||
|
|
||||||
// Fetch the edge and assert that the proof is set.
|
// Fetch the edge and assert that the proof is set.
|
||||||
dbEdge2, _, _, err := graph.FetchChannelEdgesByID(edge2.ChannelID)
|
dbEdge2, _, _, err := graph.FetchChannelEdgesByID(
|
||||||
|
ctx, edge2.ChannelID,
|
||||||
|
)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, dbEdge2.AuthProof)
|
require.NotNil(t, dbEdge2.AuthProof)
|
||||||
}
|
}
|
||||||
@@ -4486,7 +4494,9 @@ func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
|||||||
// we added is invalid according to the new format, it should be as we
|
// we added is invalid according to the new format, it should be as we
|
||||||
// are not aware of the policy (indicated by the policy returned being
|
// are not aware of the policy (indicated by the policy returned being
|
||||||
// nil)
|
// nil)
|
||||||
dbEdgeInfo, dbEdge1, dbEdge2, err := graph.FetchChannelEdgesByID(chanID)
|
dbEdgeInfo, dbEdge1, dbEdge2, err := graph.FetchChannelEdgesByID(
|
||||||
|
ctx, chanID,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch channel by ID")
|
require.NoError(t, err, "unable to fetch channel by ID")
|
||||||
|
|
||||||
// The first edge should have a nil-policy returned
|
// The first edge should have a nil-policy returned
|
||||||
@@ -4498,7 +4508,9 @@ func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
|||||||
// policies then become fully populated.
|
// policies then become fully populated.
|
||||||
require.NoError(t, graph.UpdateEdgePolicy(ctx, edge1))
|
require.NoError(t, graph.UpdateEdgePolicy(ctx, edge1))
|
||||||
|
|
||||||
dbEdgeInfo, dbEdge1, dbEdge2, err = graph.FetchChannelEdgesByID(chanID)
|
dbEdgeInfo, dbEdge1, dbEdge2, err = graph.FetchChannelEdgesByID(
|
||||||
|
ctx, chanID,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch channel by ID")
|
require.NoError(t, err, "unable to fetch channel by ID")
|
||||||
compareEdgePolicies(t, dbEdge1, edge1)
|
compareEdgePolicies(t, dbEdge1, edge1)
|
||||||
compareEdgePolicies(t, dbEdge2, edge2)
|
compareEdgePolicies(t, dbEdge2, edge2)
|
||||||
|
|||||||
@@ -311,7 +311,8 @@ type Store interface { //nolint:interfacebloat
|
|||||||
// zombie within the database. In this case, the ChannelEdgePolicy's
|
// zombie within the database. In this case, the ChannelEdgePolicy's
|
||||||
// will be nil, and the ChannelEdgeInfo will only include the public
|
// will be nil, and the ChannelEdgeInfo will only include the public
|
||||||
// keys of each node.
|
// keys of each node.
|
||||||
FetchChannelEdgesByID(v lnwire.GossipVersion, chanID uint64) (
|
FetchChannelEdgesByID(ctx context.Context, v lnwire.GossipVersion,
|
||||||
|
chanID uint64) (
|
||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error)
|
*models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
|
|||||||
@@ -3989,8 +3989,9 @@ func (c *KVStore) FetchChannelEdgesByOutpoint(v lnwire.GossipVersion,
|
|||||||
// ErrZombieEdge an be returned if the edge is currently marked as a zombie
|
// 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 ChannelEdgePolicy's will be nil, and
|
||||||
// the ChannelEdgeInfo will only include the public keys of each node.
|
// the ChannelEdgeInfo will only include the public keys of each node.
|
||||||
func (c *KVStore) FetchChannelEdgesByID(v lnwire.GossipVersion,
|
func (c *KVStore) FetchChannelEdgesByID(_ context.Context,
|
||||||
chanID uint64) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
v lnwire.GossipVersion, chanID uint64) (
|
||||||
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
if v != lnwire.GossipVersion1 {
|
if v != lnwire.GossipVersion1 {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package graphdb
|
package graphdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
@@ -412,7 +413,9 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
|
|||||||
// We'll need to fetch the edge's information from the database
|
// We'll need to fetch the edge's information from the database
|
||||||
// in order to get the information concerning which nodes are
|
// in order to get the information concerning which nodes are
|
||||||
// being connected.
|
// being connected.
|
||||||
edgeInfo, _, _, err := c.FetchChannelEdgesByID(m.ChannelID)
|
edgeInfo, _, _, err := c.FetchChannelEdgesByID(
|
||||||
|
context.TODO(), m.ChannelID,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable fetch channel edge: %w", err)
|
return fmt.Errorf("unable fetch channel edge: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2050,12 +2050,12 @@ func (s *SQLStore) DeleteChannelEdges(ctx context.Context,
|
|||||||
// the ChannelEdgeInfo will only include the public keys of each node.
|
// the ChannelEdgeInfo will only include the public keys of each node.
|
||||||
//
|
//
|
||||||
// NOTE: part of the Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) FetchChannelEdgesByID(v lnwire.GossipVersion,
|
func (s *SQLStore) FetchChannelEdgesByID(ctx context.Context,
|
||||||
chanID uint64) (*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
v lnwire.GossipVersion, chanID uint64) (
|
||||||
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.TODO()
|
|
||||||
edge *models.ChannelEdgeInfo
|
edge *models.ChannelEdgeInfo
|
||||||
policy1, policy2 *models.ChannelEdgePolicy
|
policy1, policy2 *models.ChannelEdgePolicy
|
||||||
chanIDB = channelIDToBytes(chanID)
|
chanIDB = channelIDToBytes(chanID)
|
||||||
|
|||||||
@@ -522,8 +522,16 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
|
|||||||
//nolint:ll
|
//nolint:ll
|
||||||
paths, err := blindedpath.BuildBlindedPaymentPaths(
|
paths, err := blindedpath.BuildBlindedPaymentPaths(
|
||||||
&blindedpath.BuildBlindedPathCfg{
|
&blindedpath.BuildBlindedPathCfg{
|
||||||
FindRoutes: cfg.QueryBlindedRoutes,
|
FindRoutes: cfg.QueryBlindedRoutes,
|
||||||
FetchChannelEdgesByID: cfg.Graph.FetchChannelEdgesByID,
|
FetchChannelEdgesByID: func(chanID uint64) (
|
||||||
|
*models.ChannelEdgeInfo,
|
||||||
|
*models.ChannelEdgePolicy,
|
||||||
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
|
return cfg.Graph.FetchChannelEdgesByID(
|
||||||
|
context.TODO(), chanID,
|
||||||
|
)
|
||||||
|
},
|
||||||
FetchOurOpenChannels: cfg.ChanDB.FetchAllOpenChannels,
|
FetchOurOpenChannels: cfg.ChanDB.FetchAllOpenChannels,
|
||||||
PathID: paymentAddr[:],
|
PathID: paymentAddr[:],
|
||||||
ValueMsat: invoice.Value,
|
ValueMsat: invoice.Value,
|
||||||
@@ -790,9 +798,16 @@ func newSelectHopHintsCfg(invoicesCfg *AddInvoiceConfig,
|
|||||||
FetchAllChannels: invoicesCfg.ChanDB.FetchAllChannels,
|
FetchAllChannels: invoicesCfg.ChanDB.FetchAllChannels,
|
||||||
IsChannelActive: invoicesCfg.IsChannelActive,
|
IsChannelActive: invoicesCfg.IsChannelActive,
|
||||||
IsPublicNode: invoicesCfg.Graph.IsPublicNode,
|
IsPublicNode: invoicesCfg.Graph.IsPublicNode,
|
||||||
FetchChannelEdgesByID: invoicesCfg.Graph.FetchChannelEdgesByID,
|
FetchChannelEdgesByID: func(chanID uint64) (
|
||||||
GetAlias: invoicesCfg.GetAlias,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
MaxHopHints: maxHopHints,
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
|
return invoicesCfg.Graph.FetchChannelEdgesByID(
|
||||||
|
context.TODO(), chanID,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
GetAlias: invoicesCfg.GetAlias,
|
||||||
|
MaxHopHints: maxHopHints,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package invoicesrpc
|
package invoicesrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/graph/db/models"
|
"github.com/lightningnetwork/lnd/graph/db/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,8 +11,9 @@ type GraphSource interface {
|
|||||||
// FetchChannelEdgesByID attempts to look up the two directed edges for
|
// FetchChannelEdgesByID attempts to look up the two directed edges for
|
||||||
// the channel identified by the channel ID. If the channel can't be
|
// the channel identified by the channel ID. If the channel can't be
|
||||||
// found, then graphdb.ErrEdgeNotFound is returned.
|
// found, then graphdb.ErrEdgeNotFound is returned.
|
||||||
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
FetchChannelEdgesByID(ctx context.Context, chanID uint64) (
|
||||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
|
*models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
// IsPublicNode is a helper method that determines whether the node with
|
// 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
|
// the given public key is seen as a public node in the graph from the
|
||||||
|
|||||||
@@ -2199,7 +2199,9 @@ func runRouteFailMaxHTLC(t *testing.T, useCache bool) {
|
|||||||
// Next, update the middle edge policy to only allow payments up to 100k
|
// Next, update the middle edge policy to only allow payments up to 100k
|
||||||
// msat.
|
// msat.
|
||||||
graph := ctx.testGraphInstance.graph
|
graph := ctx.testGraphInstance.graph
|
||||||
_, midEdge, _, err := graph.FetchChannelEdgesByID(firstToSecondID)
|
_, midEdge, _, err := graph.FetchChannelEdgesByID(
|
||||||
|
t.Context(), firstToSecondID,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch channel edges by ID")
|
require.NoError(t, err, "unable to fetch channel edges by ID")
|
||||||
midEdge.MessageFlags = 1
|
midEdge.MessageFlags = 1
|
||||||
midEdge.MaxHTLC = payAmt - 1
|
midEdge.MaxHTLC = payAmt - 1
|
||||||
@@ -2243,7 +2245,9 @@ func runRouteFailDisabledEdge(t *testing.T, useCache bool) {
|
|||||||
// path finding, as we don't consider the disable flag for local
|
// path finding, as we don't consider the disable flag for local
|
||||||
// channels (and roasbeef is the source).
|
// channels (and roasbeef is the source).
|
||||||
roasToPham := uint64(999991)
|
roasToPham := uint64(999991)
|
||||||
_, e1, e2, err := graph.graph.FetchChannelEdgesByID(roasToPham)
|
_, e1, e2, err := graph.graph.FetchChannelEdgesByID(
|
||||||
|
t.Context(), roasToPham,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch edge")
|
require.NoError(t, err, "unable to fetch edge")
|
||||||
e1.ChannelFlags |= lnwire.ChanUpdateDisabled
|
e1.ChannelFlags |= lnwire.ChanUpdateDisabled
|
||||||
e1.LastUpdate = e1.LastUpdate.Add(time.Second)
|
e1.LastUpdate = e1.LastUpdate.Add(time.Second)
|
||||||
@@ -2266,7 +2270,9 @@ func runRouteFailDisabledEdge(t *testing.T, useCache bool) {
|
|||||||
// Now, we'll modify the edge from phamnuwen -> sophon, to read that
|
// Now, we'll modify the edge from phamnuwen -> sophon, to read that
|
||||||
// it's disabled.
|
// it's disabled.
|
||||||
phamToSophon := uint64(99999)
|
phamToSophon := uint64(99999)
|
||||||
_, e, _, err := graph.graph.FetchChannelEdgesByID(phamToSophon)
|
_, e, _, err := graph.graph.FetchChannelEdgesByID(
|
||||||
|
t.Context(), phamToSophon,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch edge")
|
require.NoError(t, err, "unable to fetch edge")
|
||||||
e.ChannelFlags |= lnwire.ChanUpdateDisabled
|
e.ChannelFlags |= lnwire.ChanUpdateDisabled
|
||||||
e.LastUpdate = e.LastUpdate.Add(time.Second)
|
e.LastUpdate = e.LastUpdate.Add(time.Second)
|
||||||
@@ -2349,7 +2355,9 @@ func runPathSourceEdgesBandwidth(t *testing.T, useCache bool) {
|
|||||||
// Finally, set the roasbeef->songoku bandwidth, but also set its
|
// Finally, set the roasbeef->songoku bandwidth, but also set its
|
||||||
// disable flag.
|
// disable flag.
|
||||||
bandwidths.hints[roasToSongoku] = 2 * payAmt
|
bandwidths.hints[roasToSongoku] = 2 * payAmt
|
||||||
_, e1, e2, err := graph.graph.FetchChannelEdgesByID(roasToSongoku)
|
_, e1, e2, err := graph.graph.FetchChannelEdgesByID(
|
||||||
|
t.Context(), roasToSongoku,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch edge")
|
require.NoError(t, err, "unable to fetch edge")
|
||||||
e1.ChannelFlags |= lnwire.ChanUpdateDisabled
|
e1.ChannelFlags |= lnwire.ChanUpdateDisabled
|
||||||
e1.LastUpdate = e1.LastUpdate.Add(time.Second)
|
e1.LastUpdate = e1.LastUpdate.Add(time.Second)
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ func TestChannelUpdateValidation(t *testing.T) {
|
|||||||
|
|
||||||
// Assert that the initially configured fee is retrieved correctly.
|
// Assert that the initially configured fee is retrieved correctly.
|
||||||
_, e1, e2, err := ctx.graph.FetchChannelEdgesByID(
|
_, e1, e2, err := ctx.graph.FetchChannelEdgesByID(
|
||||||
lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
t.Context(), lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "cannot retrieve channel")
|
require.NoError(t, err, "cannot retrieve channel")
|
||||||
|
|
||||||
@@ -526,7 +526,7 @@ func TestChannelUpdateValidation(t *testing.T) {
|
|||||||
require.Error(t, err, "expected route to fail with channel update")
|
require.Error(t, err, "expected route to fail with channel update")
|
||||||
|
|
||||||
_, e1, e2, err = ctx.graph.FetchChannelEdgesByID(
|
_, e1, e2, err = ctx.graph.FetchChannelEdgesByID(
|
||||||
lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
t.Context(), lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "cannot retrieve channel")
|
require.NoError(t, err, "cannot retrieve channel")
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ func TestChannelUpdateValidation(t *testing.T) {
|
|||||||
// This time a valid signature was supplied and the policy change should
|
// This time a valid signature was supplied and the policy change should
|
||||||
// have been applied to the graph.
|
// have been applied to the graph.
|
||||||
_, e1, e2, err = ctx.graph.FetchChannelEdgesByID(
|
_, e1, e2, err = ctx.graph.FetchChannelEdgesByID(
|
||||||
lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
t.Context(), lnwire.NewShortChanIDFromInt(1).ToUint64(),
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "cannot retrieve channel")
|
require.NoError(t, err, "cannot retrieve channel")
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
|
|||||||
// to sophon. We'll obtain this as we'll need to to generate the
|
// to sophon. We'll obtain this as we'll need to to generate the
|
||||||
// FeeInsufficient error that we'll send back.
|
// FeeInsufficient error that we'll send back.
|
||||||
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(
|
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(
|
||||||
songokuSophonChanID,
|
t.Context(), songokuSophonChanID,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to fetch chan id")
|
require.NoError(t, err, "unable to fetch chan id")
|
||||||
|
|
||||||
@@ -936,7 +936,9 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
|
|||||||
chanID := ctx.getChannelIDFromAlias(t, "roasbeef", "songoku")
|
chanID := ctx.getChannelIDFromAlias(t, "roasbeef", "songoku")
|
||||||
roasbeefSongoku := lnwire.NewShortChanIDFromInt(chanID)
|
roasbeefSongoku := lnwire.NewShortChanIDFromInt(chanID)
|
||||||
|
|
||||||
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(chanID)
|
_, _, edgeUpdateToFail, err := ctx.graph.FetchChannelEdgesByID(
|
||||||
|
t.Context(), chanID,
|
||||||
|
)
|
||||||
require.NoError(t, err, "unable to fetch chan id")
|
require.NoError(t, err, "unable to fetch chan id")
|
||||||
|
|
||||||
errChanUpdate := lnwire.ChannelUpdate1{
|
errChanUpdate := lnwire.ChannelUpdate1{
|
||||||
|
|||||||
+6
-4
@@ -716,7 +716,9 @@ func (r *rpcServer) addDeps(ctx context.Context, s *server,
|
|||||||
FetchChannelCapacity: func(chanID uint64) (btcutil.Amount,
|
FetchChannelCapacity: func(chanID uint64) (btcutil.Amount,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
info, _, _, err := graph.FetchChannelEdgesByID(chanID)
|
info, _, _, err := graph.FetchChannelEdgesByID(
|
||||||
|
ctx, chanID,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -734,7 +736,7 @@ func (r *rpcServer) addDeps(ctx context.Context, s *server,
|
|||||||
route.Vertex, error) {
|
route.Vertex, error) {
|
||||||
|
|
||||||
info, _, _, err := graph.FetchChannelEdgesByID(
|
info, _, _, err := graph.FetchChannelEdgesByID(
|
||||||
chanID,
|
ctx, chanID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return route.Vertex{}, route.Vertex{},
|
return route.Vertex{}, route.Vertex{},
|
||||||
@@ -7106,7 +7108,7 @@ func (r *rpcServer) GetNodeMetrics(ctx context.Context,
|
|||||||
// uniquely identify the location of transaction's funding output within the
|
// uniquely identify the location of transaction's funding output within the
|
||||||
// blockchain. The former is an 8-byte integer, while the latter is a string
|
// blockchain. The former is an 8-byte integer, while the latter is a string
|
||||||
// formatted as funding_txid:output_index.
|
// formatted as funding_txid:output_index.
|
||||||
func (r *rpcServer) GetChanInfo(_ context.Context,
|
func (r *rpcServer) GetChanInfo(ctx context.Context,
|
||||||
in *lnrpc.ChanInfoRequest) (*lnrpc.ChannelEdge, error) {
|
in *lnrpc.ChanInfoRequest) (*lnrpc.ChannelEdge, error) {
|
||||||
|
|
||||||
graph := r.server.graphDB
|
graph := r.server.graphDB
|
||||||
@@ -7120,7 +7122,7 @@ func (r *rpcServer) GetChanInfo(_ context.Context,
|
|||||||
switch {
|
switch {
|
||||||
case in.ChanId != 0:
|
case in.ChanId != 0:
|
||||||
edgeInfo, edge1, edge2, err = graph.FetchChannelEdgesByID(
|
edgeInfo, edge1, edge2, err = graph.FetchChannelEdgesByID(
|
||||||
in.ChanId,
|
ctx, in.ChanId,
|
||||||
)
|
)
|
||||||
|
|
||||||
case in.ChanPoint != "":
|
case in.ChanPoint != "":
|
||||||
|
|||||||
@@ -1397,7 +1397,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr,
|
|||||||
*models.ChannelEdgePolicy, error) {
|
*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
info, e1, e2, err := s.graphDB.FetchChannelEdgesByID(
|
info, e1, e2, err := s.graphDB.FetchChannelEdgesByID(
|
||||||
scid.ToUint64(),
|
context.TODO(), scid.ToUint64(),
|
||||||
)
|
)
|
||||||
if errors.Is(err, graphdb.ErrEdgeNotFound) {
|
if errors.Is(err, graphdb.ErrEdgeNotFound) {
|
||||||
// This is unlikely but there is a slim chance of this
|
// This is unlikely but there is a slim chance of this
|
||||||
|
|||||||
Reference in new issue
Block a user