Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - parametrize inbound/outbound fractions for experiments #4787

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions p2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func DefaultConfig() Config {
MaxMessageSize: 2 << 20,
AcceptQueue: tptu.AcceptQueueLength,
EnableHolepunching: true,
InboundFraction: 0.8,
OutboundFraction: 1.1,
RelayServer: RelayServer{TTL: 20 * time.Minute, Reservations: 512},
}
}
Expand Down Expand Up @@ -71,6 +73,8 @@ type Config struct {
MinPeers int `mapstructure:"min-peers"`
LowPeers int `mapstructure:"low-peers"`
HighPeers int `mapstructure:"high-peers"`
InboundFraction float64 `mapstructure:"inbound-fraction"`
OutboundFraction float64 `mapstructure:"outbound-fraction"`
AutoscalePeers bool `mapstructure:"autoscale-peers"`
AdvertiseAddress string `mapstructure:"advertise-address"`
AcceptQueue int `mapstructure:"p2p-accept-queue"`
Expand Down Expand Up @@ -131,8 +135,8 @@ func New(_ context.Context, logger log.Log, cfg Config, prologue []byte, opts ..
// leaves a small room for outbound connections in order to
// reduce risk of network isolation
g := &gater{
inbound: int(float64(cfg.HighPeers) * 0.8),
outbound: int(float64(cfg.HighPeers) * 1.1),
inbound: int(float64(cfg.HighPeers) * cfg.InboundFraction),
outbound: int(float64(cfg.HighPeers) * cfg.OutboundFraction),
direct: map[peer.ID]struct{}{},
}
direct, err := parseIntoAddr(cfg.Direct)
Expand Down