gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/renter/hostdb/consts.go (about) 1 package hostdb 2 3 import ( 4 "time" 5 6 "gitlab.com/SkynetLabs/skyd/build" 7 ) 8 9 const ( 10 // historicInteractionDecay defines the decay of the HistoricSuccessfulInteractions 11 // and HistoricFailedInteractions after every block for a host entry. 12 historicInteractionDecay = 0.9995 13 14 // historicInteractionDecalLimit defines the number of historic 15 // interactions required before decay is applied. 16 historicInteractionDecayLimit = 500 17 18 // hostRequestTimeout indicates how long a host has to respond to a dial. 19 hostRequestTimeout = 2 * time.Minute 20 21 // hostScanDeadline indicates how long a host has to complete an entire 22 // scan. 23 hostScanDeadline = 4 * time.Minute 24 25 // maxHostDowntime specifies the maximum amount of time that a host is 26 // allowed to be offline while still being in the hostdb. 27 maxHostDowntime = maxHostDownTimeInDays * 24 * time.Hour 28 maxHostDownTimeInDays = 20 29 30 // maxSettingsLen indicates how long in bytes the host settings field is 31 // allowed to be before being ignored as a DoS attempt. 32 maxSettingsLen = 10e3 33 34 // minScans specifies the number of scans that a host should have before the 35 // scans start getting compressed. 36 minScans = 12 37 38 // minScansForSpeedup is the number of successful scan that needs to be 39 // completed before the dial up timeout for scans is reduced. This ensures 40 // that we have a sufficient sample size of scans for estimating the worst 41 // case timeout. 42 minScansForSpeedup = 25 43 44 // recentInteractionWeightLimit caps the number of recent interactions as a 45 // percentage of the historic interactions, to be certain that a large 46 // amount of activity in a short period of time does not overwhelm the 47 // score for a host. 48 // 49 // Non-stop heavy interactions for half a day can result in gaining more 50 // than half the total weight at this limit. 51 recentInteractionWeightLimit = 0.01 52 53 // saveFrequency defines how frequently the hostdb will save to disk. Hostdb 54 // will also save immediately prior to shutdown. 55 saveFrequency = 2 * time.Minute 56 57 // scanSpeedupMedianMultiplier is the number with which the median of the 58 // initial scans is multiplied to speedup the initial scan after 59 // minScansForSpeedup successful scans. 60 scanSpeedupMedianMultiplier = 5 61 62 // storageCompetitionFactor is the amount of competition we expect to have 63 // over a volume of storage on a host. If a host has 1 TB of storage 64 // remaining and we are actively uploading, it is unlikely that we will get 65 // the full 1 TB, because other renters will also be actively uploading to 66 // the host. A storageCompetitionFactor of 0.25 indicates that we will 67 // likely get 0.25 TB out of the 1 TB that the host has. 68 // 69 // TODO: Eventually we will want to set this value dynamically based on 70 // factors such as our own speed and potentially per-host characteristics. 71 // Buf for now we use a global constant. 72 storageCompetitionFactor = 0.25 73 74 // storagePenaltyExponentiation is the exponent that we apply to the storage 75 // penalty. If the host has half as much storage as we would like and the 76 // storagePenaltyExponentiation is 2, then the final score for the host 77 // would be (0.5)^2 = 0.25. 78 storagePenaltyExponentitaion = 2.0 79 80 // storageSkewMultiplier is a factor that we multiply with a host's ideal 81 // storage. The ideal storage is the amount of data that would be stored on 82 // the host if the renter's expected storage total (including redundancy) 83 // was spread evenly across all of the hosts. The skew multiplier adjusts 84 // for the fact that data will not be evenly spread across the hosts. 85 // 86 // A value of '1.0' indicates that storage is spread perfectly evenly. A 87 // value of '2.0' means that the host with the most data stored on it will 88 // have twice as much storage as it would if the data were spread perfectly 89 // evenly. Values closer to 1 mean less skew, values more than 1 mean more 90 // skew. 91 storageSkewMultiplier = 1.75 92 93 // txnFeesUpdateRatio is the amount of change we tolerate in the txnFees 94 // before we rebuild the hosttree. 95 txnFeesUpdateRatio = 0.05 // 5% 96 ) 97 98 var ( 99 // hostCheckupQuantity specifies the number of hosts that get scanned every 100 // time there is a regular scanning operation. 101 hostCheckupQuantity = build.Select(build.Var{ 102 Standard: int(2500), 103 Dev: int(6), 104 Testing: int(5), 105 }).(int) 106 107 // scanningThreads is the number of threads that will be probing hosts for 108 // their settings and checking for reliability. 109 maxScanningThreads = build.Select(build.Var{ 110 Standard: int(80), 111 Dev: int(4), 112 Testing: int(3), 113 }).(int) 114 ) 115 116 var ( 117 // maxScanSleep is the maximum amount of time that the hostdb will sleep 118 // between performing scans of the hosts. 119 maxScanSleep = build.Select(build.Var{ 120 Standard: time.Hour * 8, 121 Dev: time.Minute * 10, 122 Testing: time.Second * 5, 123 }).(time.Duration) 124 125 // scanCheckInterval is the interval used when waiting for the scanList to 126 // empty itself and for waiting on the consensus set to be synced. 127 scanCheckInterval = build.Select(build.Var{ 128 Standard: time.Second, 129 Dev: time.Second, 130 Testing: 100 * time.Millisecond, 131 }).(time.Duration) 132 133 // minScanSleep is the minimum amount of time that the hostdb will sleep 134 // between performing scans of the hosts. 135 minScanSleep = build.Select(build.Var{ 136 Standard: time.Hour + time.Minute*20, 137 Dev: time.Minute * 3, 138 Testing: time.Second * 1, 139 }).(time.Duration) 140 )