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

lightningnetwork / lnd / 14358372723

09 Apr 2025 01:26PM UTC coverage: 56.696% (-12.3%) from 69.037%
14358372723

Pull #9696

github

web-flow
Merge e2837e400 into 867d27d68
Pull Request #9696: Add `development_guidelines.md` for both human and machine

107055 of 188823 relevant lines covered (56.7%)

22721.56 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) error
19

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

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

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

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

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

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

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

63
        return edge.capacity, nil
×
64
}
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