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

lightningnetwork / lnd / 16683051882

01 Aug 2025 07:03PM UTC coverage: 54.949% (-12.1%) from 67.047%
16683051882

Pull #9455

github

web-flow
Merge 3f1f50be8 into 37523b6cb
Pull Request #9455: discovery+lnwire: add support for DNS host name in NodeAnnouncement msg

144 of 226 new or added lines in 7 files covered. (63.72%)

23852 existing lines in 290 files now uncovered.

108751 of 197912 relevant lines covered (54.95%)

22080.83 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,
UNCOV
40
        amount lnwire.MilliSatoshi) (btcutil.Amount, error) {
×
UNCOV
41

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

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

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

UNCOV
59
        edge := edgeUnifier.getEdgeNetwork(amount, 0)
×
UNCOV
60
        if edge == nil {
×
UNCOV
61
                return 0, fmt.Errorf("no edge for node pair %v -> %v "+
×
UNCOV
62
                        "(amount %v)", nodeFrom, nodeTo, amount)
×
UNCOV
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