• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 16777740336

06 Aug 2025 01:04PM UTC coverage: 54.85% (-12.1%) from 66.954%
16777740336

Pull #10135

github

web-flow
Merge 429aa830c into e512770f1
Pull Request #10135: docs: move v0.19.3 items to correct file

108702 of 198181 relevant lines covered (54.85%)

22045.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/routing/graph.go
1
package routing
2

3
import (
4
        "fmt"
5

6
        "github.com/btcsuite/btcd/btcutil"
7
        graphdb "github.com/lightningnetwork/lnd/graph/db"
8
        "github.com/lightningnetwork/lnd/lnwire"
9
        "github.com/lightningnetwork/lnd/routing/route"
10
)
11

12
// Graph is an abstract interface that provides information about nodes and
13
// edges to pathfinding.
14
type Graph interface {
15
        // ForEachNodeDirectedChannel calls the callback for every channel of
16
        // the given node.
17
        ForEachNodeDirectedChannel(nodePub route.Vertex,
18
                cb func(channel *graphdb.DirectedChannel) error,
19
                reset func()) error
20

21
        // FetchNodeFeatures returns the features of the given node.
22
        FetchNodeFeatures(nodePub route.Vertex) (*lnwire.FeatureVector, error)
23
}
24

25
// GraphSessionFactory can be used to gain access to a graphdb.NodeTraverser
26
// instance which can then be used for a path-finding session. Depending on the
27
// implementation, the session will represent a DB connection where a read-lock
28
// is being held across calls to the backing graph.
29
type GraphSessionFactory interface {
30
        // GraphSession will provide the call-back with access to a
31
        // graphdb.NodeTraverser instance which can be used to perform queries
32
        // against the channel graph.
33
        GraphSession(cb func(graph graphdb.NodeTraverser) error,
34
                reset func()) error
35
}
36

37
// FetchAmountPairCapacity determines the maximal public capacity between two
38
// nodes depending on the amount we try to send.
39
func FetchAmountPairCapacity(graph Graph, source, nodeFrom, nodeTo route.Vertex,
40
        amount lnwire.MilliSatoshi) (btcutil.Amount, error) {
×
41

×
42
        // Create unified edges for all incoming connections.
×
43
        //
×
44
        // Note: Inbound fees are not used here because this method is only used
×
45
        // by a deprecated router rpc.
×
46
        u := newNodeEdgeUnifier(source, nodeTo, false, nil)
×
47

×
48
        err := u.addGraphPolicies(graph)
×
49
        if err != nil {
×
50
                return 0, err
×
51
        }
×
52

53
        edgeUnifier, ok := u.edgeUnifiers[nodeFrom]
×
54
        if !ok {
×
55
                return 0, fmt.Errorf("no edge info for node pair %v -> %v",
×
56
                        nodeFrom, nodeTo)
×
57
        }
×
58

59
        edge := edgeUnifier.getEdgeNetwork(amount, 0)
×
60
        if edge == nil {
×
61
                return 0, fmt.Errorf("no edge for node pair %v -> %v "+
×
62
                        "(amount %v)", nodeFrom, nodeTo, amount)
×
63
        }
×
64

65
        return edge.capacity, nil
×
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc