• 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

55.74
/lnwire/gossip_timestamp_range.go
1
package lnwire
2

3
import (
4
        "bytes"
5
        "io"
6

7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "github.com/lightningnetwork/lnd/tlv"
9
)
10

11
// GossipTimestampRange is a message that allows the sender to restrict the set
12
// of future gossip announcements sent by the receiver. Nodes should send this
13
// if they have the gossip-queries feature bit active. Nodes are able to send
14
// new GossipTimestampRange messages to replace the prior window.
15
type GossipTimestampRange struct {
16
        // ChainHash denotes the chain that the sender wishes to restrict the
17
        // set of received announcements of.
18
        ChainHash chainhash.Hash
19

20
        // FirstTimestamp is the timestamp of the earliest announcement message
21
        // that should be sent by the receiver. This is only to be used for
22
        // querying message of gossip 1.0 which are timestamped using Unix
23
        // timestamps. FirstBlockHeight and BlockRange should be used to
24
        // query for announcement messages timestamped using block heights.
25
        FirstTimestamp uint32
26

27
        // TimestampRange is the horizon beyond the FirstTimestamp that any
28
        // announcement messages should be sent for. The receiving node MUST
29
        // NOT send any announcements that have a timestamp greater than
30
        // FirstTimestamp + TimestampRange. This is used together with
31
        // FirstTimestamp to query for gossip 1.0 messages timestamped with
32
        // Unix timestamps.
33
        TimestampRange uint32
34

35
        // FirstBlockHeight is the height of earliest announcement message that
36
        // should be sent by the receiver. This is used only for querying
37
        // announcement messages that use block heights as a timestamp.
38
        FirstBlockHeight tlv.OptionalRecordT[tlv.TlvType2, uint32]
39

40
        // BlockRange is the horizon beyond FirstBlockHeight that any
41
        // announcement messages should be sent for. The receiving node MUST NOT
42
        // send any announcements that have a timestamp greater than
43
        // FirstBlockHeight + BlockRange.
44
        BlockRange tlv.OptionalRecordT[tlv.TlvType4, uint32]
45

46
        // ExtraData is the set of data that was appended to this message to
47
        // fill out the full maximum transport message size. These fields can
48
        // be used to specify optional data such as custom TLV fields.
49
        ExtraData ExtraOpaqueData
50
}
51

52
// NewGossipTimestampRange creates a new empty GossipTimestampRange message.
53
func NewGossipTimestampRange() *GossipTimestampRange {
×
54
        return &GossipTimestampRange{}
×
55
}
×
56

57
// A compile time check to ensure GossipTimestampRange implements the
58
// lnwire.Message interface.
59
var _ Message = (*GossipTimestampRange)(nil)
60

61
// Decode deserializes a serialized GossipTimestampRange message stored in the
62
// passed io.Reader observing the specified protocol version.
63
//
64
// This is part of the lnwire.Message interface.
65
func (g *GossipTimestampRange) Decode(r io.Reader, _ uint32) error {
3✔
66
        err := ReadElements(r,
3✔
67
                g.ChainHash[:],
3✔
68
                &g.FirstTimestamp,
3✔
69
                &g.TimestampRange,
3✔
70
        )
3✔
71
        if err != nil {
3✔
72
                return err
×
73
        }
×
74

75
        var tlvRecords ExtraOpaqueData
3✔
76
        if err := ReadElements(r, &tlvRecords); err != nil {
3✔
77
                return err
×
78
        }
×
79

80
        var (
3✔
81
                firstBlock = tlv.ZeroRecordT[tlv.TlvType2, uint32]()
3✔
82
                blockRange = tlv.ZeroRecordT[tlv.TlvType4, uint32]()
3✔
83
        )
3✔
84
        typeMap, err := tlvRecords.ExtractRecords(&firstBlock, &blockRange)
3✔
85
        if err != nil {
3✔
86
                return err
×
87
        }
×
88

89
        if val, ok := typeMap[g.FirstBlockHeight.TlvType()]; ok && val == nil {
3✔
90
                g.FirstBlockHeight = tlv.SomeRecordT(firstBlock)
×
91
        }
×
92
        if val, ok := typeMap[g.BlockRange.TlvType()]; ok && val == nil {
3✔
93
                g.BlockRange = tlv.SomeRecordT(blockRange)
×
94
        }
×
95

96
        if len(tlvRecords) != 0 {
3✔
97
                g.ExtraData = tlvRecords
×
98
        }
×
99

100
        return nil
3✔
101
}
102

103
// Encode serializes the target GossipTimestampRange into the passed io.Writer
104
// observing the protocol version specified.
105
//
106
// This is part of the lnwire.Message interface.
107
func (g *GossipTimestampRange) Encode(w *bytes.Buffer, pver uint32) error {
3✔
108
        if err := WriteBytes(w, g.ChainHash[:]); err != nil {
3✔
109
                return err
×
110
        }
×
111

112
        if err := WriteUint32(w, g.FirstTimestamp); err != nil {
3✔
113
                return err
×
114
        }
×
115

116
        if err := WriteUint32(w, g.TimestampRange); err != nil {
3✔
117
                return err
×
118
        }
×
119

120
        recordProducers := make([]tlv.RecordProducer, 0, 2)
3✔
121
        g.FirstBlockHeight.WhenSome(
3✔
122
                func(height tlv.RecordT[tlv.TlvType2, uint32]) {
3✔
123
                        recordProducers = append(recordProducers, &height)
×
124
                },
×
125
        )
126
        g.BlockRange.WhenSome(
3✔
127
                func(blockRange tlv.RecordT[tlv.TlvType4, uint32]) {
3✔
128
                        recordProducers = append(recordProducers, &blockRange)
×
129
                },
×
130
        )
131
        err := EncodeMessageExtraData(&g.ExtraData, recordProducers...)
3✔
132
        if err != nil {
3✔
133
                return err
×
134
        }
×
135

136
        return WriteBytes(w, g.ExtraData)
3✔
137
}
138

139
// MsgType returns the integer uniquely identifying this message type on the
140
// wire.
141
//
142
// This is part of the lnwire.Message interface.
143
func (g *GossipTimestampRange) MsgType() MessageType {
3✔
144
        return MsgGossipTimestampRange
3✔
145
}
3✔
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