You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

9 years ago
9 years ago
  1. package p2p
  2. import (
  3. cfg "github.com/tendermint/go-config"
  4. )
  5. const (
  6. // Switch config keys
  7. configKeyDialTimeoutSeconds = "dial_timeout_seconds"
  8. configKeyHandshakeTimeoutSeconds = "handshake_timeout_seconds"
  9. configKeyMaxNumPeers = "max_num_peers"
  10. configKeyAuthEnc = "authenticated_encryption"
  11. // MConnection config keys
  12. configKeySendRate = "send_rate"
  13. configKeyRecvRate = "recv_rate"
  14. // Fuzz params
  15. configFuzzEnable = "fuzz_enable" // use the fuzz wrapped conn
  16. configFuzzActive = "fuzz_active" // toggle fuzzing
  17. configFuzzMode = "fuzz_mode" // eg. drop, delay
  18. configFuzzMaxDelayMilliseconds = "fuzz_max_delay_milliseconds"
  19. configFuzzProbDropRW = "fuzz_prob_drop_rw"
  20. configFuzzProbDropConn = "fuzz_prob_drop_conn"
  21. configFuzzProbSleep = "fuzz_prob_sleep"
  22. )
  23. func setConfigDefaults(config cfg.Config) {
  24. // Switch default config
  25. config.SetDefault(configKeyDialTimeoutSeconds, 3)
  26. config.SetDefault(configKeyHandshakeTimeoutSeconds, 20)
  27. config.SetDefault(configKeyMaxNumPeers, 50)
  28. config.SetDefault(configKeyAuthEnc, true)
  29. // MConnection default config
  30. config.SetDefault(configKeySendRate, 512000) // 500KB/s
  31. config.SetDefault(configKeyRecvRate, 512000) // 500KB/s
  32. // Fuzz defaults
  33. config.SetDefault(configFuzzEnable, false)
  34. config.SetDefault(configFuzzActive, false)
  35. config.SetDefault(configFuzzMode, FuzzModeDrop)
  36. config.SetDefault(configFuzzMaxDelayMilliseconds, 3000)
  37. config.SetDefault(configFuzzProbDropRW, 0.2)
  38. config.SetDefault(configFuzzProbDropConn, 0.00)
  39. config.SetDefault(configFuzzProbSleep, 0.00)
  40. }