Fix RSConfig calculation in testplanet.Uplink.GetConfig (#1770)

This commit is contained in:
Kaloyan Raev 2019-04-17 17:00:00 +03:00 committed by GitHub
parent 5b3c146d8a
commit 860c5d86d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -298,10 +298,10 @@ func (uplink *Uplink) GetConfig(satellite *satellite.Peer) uplink.Config {
config.Client.SatelliteAddr = satellite.Addr()
config.Client.APIKey = uplink.APIKey[satellite.ID()]
config.RS.MinThreshold = 1 * uplink.StorageNodeCount / 5
config.RS.RepairThreshold = 2 * uplink.StorageNodeCount / 5
config.RS.SuccessThreshold = 3 * uplink.StorageNodeCount / 5
config.RS.MaxThreshold = 4 * uplink.StorageNodeCount / 5
config.RS.MinThreshold = atLeastOne(uplink.StorageNodeCount * 1 / 5) // 20% of storage nodes
config.RS.RepairThreshold = atLeastOne(uplink.StorageNodeCount * 2 / 5) // 40% of storage nodes
config.RS.SuccessThreshold = atLeastOne(uplink.StorageNodeCount * 3 / 5) // 60% of storage nodes
config.RS.MaxThreshold = atLeastOne(uplink.StorageNodeCount * 4 / 5) // 80% of storage nodes
config.TLS.UsePeerCAWhitelist = false
config.TLS.Extensions.Revocation = false
@ -315,3 +315,11 @@ func getDefaultConfig() uplink.Config {
cfgstruct.Bind(&pflag.FlagSet{}, &config, true)
return config
}
// atLeastOne returns 1 if value < 1, or value otherwise.
func atLeastOne(value int) int {
if value < 1 {
return 1
}
return value
}