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