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

lightningnetwork / lnd / 13035292482

29 Jan 2025 03:59PM UTC coverage: 49.3% (-9.5%) from 58.777%
13035292482

Pull #9456

github

mohamedawnallah
docs: update release-notes-0.19.0.md

In this commit, we warn users about the removal
of RPCs `SendToRoute`, `SendToRouteSync`, `SendPayment`,
and `SendPaymentSync` in the next release 0.20.
Pull Request #9456: lnrpc+docs: deprecate warning `SendToRoute`, `SendToRouteSync`, `SendPayment`, and `SendPaymentSync` in Release 0.19

100634 of 204126 relevant lines covered (49.3%)

1.54 hits per line

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

84.44
/htlcswitch/held_htlc_set.go
1
package htlcswitch
2

3
import (
4
        "errors"
5
        "fmt"
6

7
        "github.com/lightningnetwork/lnd/graph/db/models"
8
)
9

10
// heldHtlcSet keeps track of outstanding intercepted forwards. It exposes
11
// several methods to manipulate the underlying map structure in a consistent
12
// way.
13
type heldHtlcSet struct {
14
        set map[models.CircuitKey]InterceptedForward
15
}
16

17
func newHeldHtlcSet() *heldHtlcSet {
3✔
18
        return &heldHtlcSet{
3✔
19
                set: make(map[models.CircuitKey]InterceptedForward),
3✔
20
        }
3✔
21
}
3✔
22

23
// forEach iterates over all held forwards and calls the given callback for each
24
// of them.
25
func (h *heldHtlcSet) forEach(cb func(InterceptedForward)) {
3✔
26
        for _, fwd := range h.set {
6✔
27
                cb(fwd)
3✔
28
        }
3✔
29
}
30

31
// popAll calls the callback for each forward and removes them from the set.
32
func (h *heldHtlcSet) popAll(cb func(InterceptedForward)) {
3✔
33
        for _, fwd := range h.set {
6✔
34
                cb(fwd)
3✔
35
        }
3✔
36

37
        h.set = make(map[models.CircuitKey]InterceptedForward)
3✔
38
}
39

40
// popAutoFails calls the callback for each forward that has an auto-fail height
41
// equal or less then the specified pop height and removes them from the set.
42
func (h *heldHtlcSet) popAutoFails(height uint32, cb func(InterceptedForward)) {
3✔
43
        for key, fwd := range h.set {
6✔
44
                if uint32(fwd.Packet().AutoFailHeight) > height {
6✔
45
                        continue
3✔
46
                }
47

48
                cb(fwd)
×
49

×
50
                delete(h.set, key)
×
51
        }
52
}
53

54
// pop returns the specified forward and removes it from the set.
55
func (h *heldHtlcSet) pop(key models.CircuitKey) (InterceptedForward, error) {
3✔
56
        intercepted, ok := h.set[key]
3✔
57
        if !ok {
6✔
58
                return nil, fmt.Errorf("fwd %v not found", key)
3✔
59
        }
3✔
60

61
        delete(h.set, key)
3✔
62

3✔
63
        return intercepted, nil
3✔
64
}
65

66
// exists tests whether the specified forward is part of the set.
67
func (h *heldHtlcSet) exists(key models.CircuitKey) bool {
3✔
68
        _, ok := h.set[key]
3✔
69

3✔
70
        return ok
3✔
71
}
3✔
72

73
// push adds the specified forward to the set. An error is returned if the
74
// forward exists already.
75
func (h *heldHtlcSet) push(key models.CircuitKey,
76
        fwd InterceptedForward) error {
3✔
77

3✔
78
        if fwd == nil {
3✔
79
                return errors.New("nil fwd pushed")
×
80
        }
×
81

82
        if h.exists(key) {
3✔
83
                return errors.New("htlc already exists in set")
×
84
        }
×
85

86
        h.set[key] = fwd
3✔
87

3✔
88
        return nil
3✔
89
}
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