mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
config+server+networktest: make trickleDelay configurable
Add option to set trickleDelay for AuthenticatedGossiper in command line, with default value of 300 milliseconds. Pass this value to newServer, which uses it when creating a new instance of AuthenticatedGossiper. Also set this value to 300 milliseconds when creating nodes in integration tests.
This commit is contained in:
parent
39d38da732
commit
ed6ad22e85
@ -36,6 +36,7 @@ const (
|
||||
defaultMaxPendingChannels = 1
|
||||
defaultNumChanConfs = 1
|
||||
defaultNoEncryptWallet = false
|
||||
defaultTrickleDelay = 30 * 1000
|
||||
)
|
||||
|
||||
var (
|
||||
@ -130,7 +131,10 @@ type config struct {
|
||||
|
||||
NoNetBootstrap bool `long:"nobootstrap" description:"If true, then automatic network bootstrapping will not be attempted."`
|
||||
|
||||
|
||||
NoEncryptWallet bool `long:"noencryptwallet" description:"If set, wallet will be encrypted using the default passphrase."`
|
||||
|
||||
TrickleDelay int `long:"trickledelay" description:"Time in milliseconds between each release of announcements to the network"`
|
||||
}
|
||||
|
||||
// loadConfig initializes and parses the config using a config file and command
|
||||
@ -169,6 +173,7 @@ func loadConfig() (*config, error) {
|
||||
MaxChannels: 5,
|
||||
Allocation: 0.6,
|
||||
},
|
||||
TrickleDelay: defaultTrickleDelay,
|
||||
}
|
||||
|
||||
// Pre-parse the command line options to pick up an alternative config
|
||||
|
@ -81,7 +81,7 @@ type Config struct {
|
||||
// exchange the channel announcement proofs.
|
||||
ProofMatureDelta uint32
|
||||
|
||||
// TrickleDelay the period of trickle timer which flushing to the
|
||||
// TrickleDelay the period of trickle timer which flushes to the
|
||||
// network the pending batch of new announcements we've received since
|
||||
// the last trickle tick.
|
||||
TrickleDelay time.Duration
|
||||
@ -383,10 +383,10 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
|
||||
return nMsg.err
|
||||
}
|
||||
|
||||
// ChannelUpdateID is a unique identifier for ChannelUpdate messages, as
|
||||
// channelUpdateID is a unique identifier for ChannelUpdate messages, as
|
||||
// channel updates can be identified by the (ShortChannelID, Flags)
|
||||
// tuple.
|
||||
type ChannelUpdateID struct {
|
||||
type channelUpdateID struct {
|
||||
// channelID represents the set of data which is needed to
|
||||
// retrieve all necessary data to validate the channel existence.
|
||||
channelID lnwire.ShortChannelID
|
||||
@ -394,7 +394,7 @@ type ChannelUpdateID struct {
|
||||
// Flags least-significant bit must be set to 0 if the creating node
|
||||
// corresponds to the first node in the previously sent channel
|
||||
// announcement and 1 otherwise.
|
||||
Flags uint16
|
||||
flags uint16
|
||||
}
|
||||
|
||||
// deDupedAnnouncements de-duplicates announcements that have been
|
||||
@ -407,10 +407,10 @@ type deDupedAnnouncements struct {
|
||||
channelAnnouncements map[lnwire.ShortChannelID]lnwire.Message
|
||||
|
||||
// channelUpdates are identified by the channel update id field.
|
||||
channelUpdates map[ChannelUpdateID]lnwire.Message
|
||||
channelUpdates map[channelUpdateID]lnwire.Message
|
||||
|
||||
// nodeAnnouncements are identified by node id field.
|
||||
nodeAnnouncements map[*btcec.PublicKey]lnwire.Message
|
||||
// nodeAnnouncements are identified by the Vertex field.
|
||||
nodeAnnouncements map[routing.Vertex]lnwire.Message
|
||||
}
|
||||
|
||||
// Reset operates on deDupedAnnouncements to reset storage of announcements
|
||||
@ -419,8 +419,8 @@ func (d *deDupedAnnouncements) Reset() {
|
||||
// updates, node announcements) is set to an empty map where the
|
||||
// approprate key points to the corresponding lnwire.Message.
|
||||
d.channelAnnouncements = make(map[lnwire.ShortChannelID]lnwire.Message)
|
||||
d.channelUpdates = make(map[ChannelUpdateID]lnwire.Message)
|
||||
d.nodeAnnouncements = make(map[*btcec.PublicKey]lnwire.Message)
|
||||
d.channelUpdates = make(map[channelUpdateID]lnwire.Message)
|
||||
d.nodeAnnouncements = make(map[routing.Vertex]lnwire.Message)
|
||||
}
|
||||
|
||||
// AddMsg adds a new message to the current batch.
|
||||
@ -438,15 +438,17 @@ func (d *deDupedAnnouncements) AddMsg(message lnwire.Message) {
|
||||
case *lnwire.ChannelUpdate:
|
||||
// Channel updates are identified by the (short channel id,
|
||||
// flags) tuple.
|
||||
channelUpdateID := ChannelUpdateID{
|
||||
channelUpdateID := channelUpdateID{
|
||||
msg.ShortChannelID,
|
||||
msg.Flags,
|
||||
}
|
||||
|
||||
d.channelUpdates[channelUpdateID] = msg
|
||||
case *lnwire.NodeAnnouncement:
|
||||
// Node announcements are identified by the node id field.
|
||||
d.nodeAnnouncements[msg.NodeID] = msg
|
||||
// Node announcements are identified by the Vertex field.
|
||||
// Use the NodeID to create the corresponding Vertex.
|
||||
vertex := routing.NewVertex(msg.NodeID)
|
||||
d.nodeAnnouncements[vertex] = msg
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,10 @@ var (
|
||||
// seed nodes to log files.
|
||||
logOutput = flag.Bool("logoutput", false,
|
||||
"log output from node n to file outputn.log")
|
||||
|
||||
// trickleDelay is the amount of time in milliseconds between each
|
||||
// release of announcements by AuthenticatedGossiper to the network.
|
||||
trickleDelay = 300
|
||||
)
|
||||
|
||||
// generateListeningPorts returns two strings representing ports to listen on
|
||||
@ -187,6 +191,7 @@ func (l *lightningNode) genArgs() []string {
|
||||
args = append(args, fmt.Sprintf("--configfile=%v", l.cfg.DataDir))
|
||||
args = append(args, fmt.Sprintf("--adminmacaroonpath=%v", l.cfg.AdminMacPath))
|
||||
args = append(args, fmt.Sprintf("--readonlymacaroonpath=%v", l.cfg.ReadMacPath))
|
||||
args = append(args, fmt.Sprintf("--trickledelay=%v", trickleDelay))
|
||||
|
||||
if l.extraArgs != nil {
|
||||
args = append(args, l.extraArgs...)
|
||||
|
@ -295,7 +295,7 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
|
||||
Broadcast: s.BroadcastMessage,
|
||||
SendToPeer: s.SendToPeer,
|
||||
ProofMatureDelta: 0,
|
||||
TrickleDelay: time.Millisecond * 300,
|
||||
TrickleDelay: time.Millisecond * time.Duration(cfg.TrickleDelay),
|
||||
RetransmitDelay: time.Minute * 30,
|
||||
DB: chanDB,
|
||||
AnnSigner: s.nodeSigner,
|
||||
|
Loading…
Reference in New Issue
Block a user