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

lightningnetwork / lnd / 18016273007

25 Sep 2025 05:55PM UTC coverage: 54.653% (-12.0%) from 66.622%
18016273007

Pull #10248

github

web-flow
Merge 128443298 into b09b20c69
Pull Request #10248: Enforce TLV when creating a Route

25 of 30 new or added lines in 4 files covered. (83.33%)

23906 existing lines in 281 files now uncovered.

109536 of 200421 relevant lines covered (54.65%)

21816.97 hits per line

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

0.0
/lncfg/gossip.go
1
package lncfg
2

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

7
        "github.com/lightningnetwork/lnd/discovery"
8
        "github.com/lightningnetwork/lnd/lnwire"
9
        "github.com/lightningnetwork/lnd/routing/route"
10
)
11

12
// minAnnouncementConf defines the minimal num of confs needed for the config
13
// AnnouncementConf. We choose 3 here as it's unlikely a reorg depth of 3 would
14
// happen.
15
//
16
// NOTE: The specs recommends setting this value to 6, which is the default
17
// value used for AnnouncementConf. However the receiver should be able to
18
// decide which channels to be included in its local graph, more details can be
19
// found:
20
// - https://github.com/lightning/bolts/pull/1215#issuecomment-2557337202
21
const minAnnouncementConf = 3
22

23
//nolint:ll
24
type Gossip struct {
25
        PinnedSyncersRaw []string `long:"pinned-syncers" description:"A set of peers that should always remain in an active sync state, which can be used to closely synchronize the routing tables of two nodes. The value should be a hex-encoded pubkey, the flag can be specified multiple times to add multiple peers. Connected peers matching this pubkey will remain active for the duration of the connection and not count towards the NumActiveSyncer count."`
26

27
        PinnedSyncers discovery.PinnedSyncers
28

29
        MaxChannelUpdateBurst int `long:"max-channel-update-burst" description:"The maximum number of updates for a specific channel and direction that lnd will accept over the channel update interval."`
30

31
        ChannelUpdateInterval time.Duration `long:"channel-update-interval" description:"The interval used to determine how often lnd should allow a burst of new updates for a specific channel and direction."`
32

33
        SubBatchDelay time.Duration `long:"sub-batch-delay" description:"The duration to wait before sending the next announcement batch if there are multiple. Use a small value if there are a lot announcements and they need to be broadcast quickly."`
34

35
        AnnouncementConf uint32 `long:"announcement-conf" description:"The number of confirmations required before processing channel announcements."`
36

37
        MsgRateBytes uint64 `long:"msg-rate-bytes" description:"The total rate of outbound gossip messages, expressed in bytes per second. This setting controls the long-term average speed of gossip traffic sent from your node. The rate limit is applied globally across all peers, not per-peer. If the rate of outgoing messages exceeds this value, lnd will start to queue and delay messages to stay within the limit."`
38

39
        MsgBurstBytes uint64 `long:"msg-burst-bytes" description:"The maximum burst of outbound gossip data, in bytes, that can be sent at once. This works in conjunction with gossip.msg-rate-bytes as part of a token bucket rate-limiting scheme. This value represents the size of the token bucket. It allows for short, high-speed bursts of traffic, with the long-term rate controlled by gossip.msg-rate-bytes. This value must be larger than the maximum lightning message size (~65KB) to allow sending large gossip messages."`
40

41
        FilterConcurrency int `long:"filter-concurrency" description:"The maximum number of concurrent gossip filter applications that can be processed. If not set, defaults to 5."`
42

43
        BanThreshold uint64 `long:"ban-threshold" description:"The score at which a peer is banned. A peer's ban score is incremented for each invalid gossip message. Invalid messages include those with bad signatures, stale timestamps, excessive updates, or invalid chain data. Once the score reaches this threshold, the peer is banned. Set to 0 to disable banning."`
44

45
        PeerMsgRateBytes uint64 `long:"peer-msg-rate-bytes" description:"The peer-specific rate of outbound gossip messages, expressed in bytes per second. This setting controls the long-term average speed of gossip traffic sent from your node. The rate limit is applied to each peer. If the rate of outgoing messages exceeds this value, lnd will start to queue and delay messages sending to that peer to stay within the limit."`
46
}
47

48
// Parse the pubkeys for the pinned syncers.
UNCOV
49
func (g *Gossip) Parse() error {
×
UNCOV
50
        pinnedSyncers := make(discovery.PinnedSyncers)
×
UNCOV
51
        for _, pubkeyStr := range g.PinnedSyncersRaw {
×
UNCOV
52
                vertex, err := route.NewVertexFromStr(pubkeyStr)
×
UNCOV
53
                if err != nil {
×
54
                        return err
×
55
                }
×
UNCOV
56
                pinnedSyncers[vertex] = struct{}{}
×
57
        }
58

UNCOV
59
        g.PinnedSyncers = pinnedSyncers
×
UNCOV
60

×
UNCOV
61
        return nil
×
62
}
63

64
// Validate checks the Gossip configuration to ensure that the input values are
65
// sane.
UNCOV
66
func (g *Gossip) Validate() error {
×
UNCOV
67
        if g.AnnouncementConf < minAnnouncementConf {
×
68
                return fmt.Errorf("announcement-conf=%v must be no less than "+
×
69
                        "%v", g.AnnouncementConf, minAnnouncementConf)
×
70
        }
×
71

UNCOV
72
        if g.MsgBurstBytes < lnwire.MaxSliceLength {
×
73
                return fmt.Errorf("msg-burst-bytes=%v must be at least %v",
×
74
                        g.MsgBurstBytes, lnwire.MaxSliceLength)
×
75
        }
×
76

UNCOV
77
        if g.MsgBurstBytes <= g.MsgRateBytes {
×
78
                return fmt.Errorf("msg-burst-bytes=%v must be greater than "+
×
79
                        "msg-rate-bytes=%v", g.MsgBurstBytes, g.MsgRateBytes)
×
80
        }
×
81

UNCOV
82
        if g.MsgRateBytes <= g.PeerMsgRateBytes {
×
83
                return fmt.Errorf("msg-rate-bytes=%v must be greater than "+
×
84
                        "peer-msg-rate-bytes=%v", g.MsgRateBytes,
×
85
                        g.PeerMsgRateBytes)
×
86
        }
×
87

UNCOV
88
        return nil
×
89
}
90

91
// Compile-time constraint to ensure Gossip implements the Validator interface.
92
var _ Validator = (*Gossip)(nil)
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