Skip to content

Commit

Permalink
config+server+networktest: make trickleDelay configurable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
flaurida committed Sep 21, 2017
1 parent b7b623f commit a9a107e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
defaultRPCHost = "localhost"
defaultMaxPendingChannels = 1
defaultNumChanConfs = 1
defaultTrickleDelay = 300
)

var (
Expand Down Expand Up @@ -125,6 +126,8 @@ type config struct {
Autopilot *autoPilotConfig `group:"autopilot" namespace:"autopilot"`

NoNetBootstrap bool `long:"nobootstrap" description:"If true, then automatic network bootstrapping will not be attempted."`

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
Expand Down Expand Up @@ -162,6 +165,7 @@ func loadConfig() (*config, error) {
MaxChannels: 5,
Allocation: 0.6,
},
TrickleDelay: defaultTrickleDelay,
}

// Pre-parse the command line options to pick up an alternative config
Expand Down
2 changes: 1 addition & 1 deletion discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
Expand Down
5 changes: 5 additions & 0 deletions networktest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,6 +131,7 @@ func newLightningNode(btcrpcConfig *rpcclient.ConnConfig, lndArgs []string) (*li
RPCUser: btcrpcConfig.User,
RPCPass: btcrpcConfig.Pass,
},
TrickleDelay: trickleDelay,
}

nodeNum := numActiveNodes
Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,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),
DB: chanDB,
AnnSigner: s.nodeSigner,
},
Expand Down

0 comments on commit a9a107e

Please sign in to comment.