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

lightningnetwork / lnd / 12343072627

15 Dec 2024 11:09PM UTC coverage: 57.504% (-1.1%) from 58.636%
12343072627

Pull #9315

github

yyforyongyu
contractcourt: offer outgoing htlc one block earlier before its expiry

We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
Pull Request #9315: Implement `blockbeat`

1445 of 2007 new or added lines in 26 files covered. (72.0%)

19246 existing lines in 249 files now uncovered.

102342 of 177975 relevant lines covered (57.5%)

24772.24 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
        // ForEachNodeChannel calls the callback for every channel of the given
16
        // node.
17
        ForEachNodeChannel(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 produce a new Graph instance which can
25
// then be used for a path-finding session. Depending on the implementation,
26
// the Graph session will represent a DB connection where a read-lock is being
27
// held across calls to the backing Graph.
28
type GraphSessionFactory interface {
29
        // NewGraphSession will produce a new Graph to use for a path-finding
30
        // session. It returns the Graph along with a call-back that must be
31
        // called once Graph access is complete. This call-back will close any
32
        // read-only transaction that was created at Graph construction time.
33
        NewGraphSession() (Graph, func() error, error)
34
}
35

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

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

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

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

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

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