mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
* Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package trust
|
|
|
|
import "time"
|
|
|
|
// MetricConfig - Configures the weight functions and time intervals for the metric
|
|
type MetricConfig struct {
|
|
// Determines the percentage given to current behavior
|
|
ProportionalWeight float64
|
|
|
|
// Determines the percentage given to prior behavior
|
|
IntegralWeight float64
|
|
|
|
// The window of time that the trust metric will track events across.
|
|
// This can be set to cover many days without issue
|
|
TrackingWindow time.Duration
|
|
|
|
// Each interval should be short for adapability.
|
|
// Less than 30 seconds is too sensitive,
|
|
// and greater than 5 minutes will make the metric numb
|
|
IntervalLength time.Duration
|
|
}
|
|
|
|
// DefaultConfig returns a config with values that have been tested and produce desirable results
|
|
func DefaultConfig() MetricConfig {
|
|
return MetricConfig{
|
|
ProportionalWeight: 0.4,
|
|
IntegralWeight: 0.6,
|
|
TrackingWindow: (time.Minute * 60 * 24) * 14, // 14 days.
|
|
IntervalLength: 1 * time.Minute,
|
|
}
|
|
}
|
|
|
|
// Ensures that all configuration elements have valid values
|
|
func customConfig(tmc MetricConfig) MetricConfig {
|
|
config := DefaultConfig()
|
|
|
|
// Check the config for set values, and setup appropriately
|
|
if tmc.ProportionalWeight > 0 {
|
|
config.ProportionalWeight = tmc.ProportionalWeight
|
|
}
|
|
|
|
if tmc.IntegralWeight > 0 {
|
|
config.IntegralWeight = tmc.IntegralWeight
|
|
}
|
|
|
|
if tmc.IntervalLength > time.Duration(0) {
|
|
config.IntervalLength = tmc.IntervalLength
|
|
}
|
|
|
|
if tmc.TrackingWindow > time.Duration(0) &&
|
|
tmc.TrackingWindow >= config.IntervalLength {
|
|
config.TrackingWindow = tmc.TrackingWindow
|
|
}
|
|
return config
|
|
}
|