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

lightningnetwork / lnd / 13566028875

27 Feb 2025 12:09PM UTC coverage: 49.396% (-9.4%) from 58.748%
13566028875

Pull #9555

github

ellemouton
graph/db: populate the graph cache in Start instead of during construction

In this commit, we move the graph cache population logic out of the
ChannelGraph constructor and into its Start method instead.
Pull Request #9555: graph: extract cache from CRUD [6]

34 of 54 new or added lines in 4 files covered. (62.96%)

27464 existing lines in 436 files now uncovered.

101095 of 204664 relevant lines covered (49.4%)

1.54 hits per line

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

78.95
/lnwire/typed_lease_expiry.go
1
package lnwire
2

3
import (
4
        "io"
5

6
        "github.com/lightningnetwork/lnd/tlv"
7
)
8

9
const (
10
        // LeaseExpiryType is the type of the experimental record used to
11
        // communicate the expiration of a channel lease throughout the channel
12
        // funding process.
13
        //
14
        // TODO: Decide on actual TLV type. Custom records start at 2^16.
15
        LeaseExpiryRecordType tlv.Type = 1 << 16
16
)
17

18
// LeaseExpiry represents the absolute expiration height of a channel lease. All
19
// outputs that pay directly to the channel initiator are locked until this
20
// height is reached.
21
type LeaseExpiry uint32
22

23
// Record returns a TLV record that can be used to encode/decode the LeaseExpiry
24
// type from a given TLV stream.
25
func (l *LeaseExpiry) Record() tlv.Record {
3✔
26
        return tlv.MakeStaticRecord(
3✔
27
                LeaseExpiryRecordType, l, 4, leaseExpiryEncoder, leaseExpiryDecoder,
3✔
28
        )
3✔
29
}
3✔
30

31
// leaseExpiryEncoder is a custom TLV encoder for the LeaseExpiry record.
32
func leaseExpiryEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
3✔
33
        if v, ok := val.(*LeaseExpiry); ok {
6✔
34
                return tlv.EUint32T(w, uint32(*v), buf)
3✔
35
        }
3✔
36

37
        return tlv.NewTypeForEncodingErr(val, "lnwire.LeaseExpiry")
×
38
}
39

40
// leaseExpiryDecoder is a custom TLV decoder for the LeaseExpiry record.
41
func leaseExpiryDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error {
3✔
42
        if v, ok := val.(*LeaseExpiry); ok {
6✔
43
                var leaseExpiry uint32
3✔
44
                if err := tlv.DUint32(r, &leaseExpiry, buf, l); err != nil {
3✔
UNCOV
45
                        return err
×
UNCOV
46
                }
×
47
                *v = LeaseExpiry(leaseExpiry)
3✔
48
                return nil
3✔
49
        }
50

51
        return tlv.NewTypeForEncodingErr(val, "lnwire.LeaseExpiry")
×
52
}
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