gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/renter/contractor/consts.go (about) 1 package contractor 2 3 import ( 4 "gitlab.com/SiaPrime/SiaPrime/build" 5 "gitlab.com/SiaPrime/SiaPrime/modules" 6 "gitlab.com/SiaPrime/SiaPrime/types" 7 ) 8 9 // Constants related to contract formation parameters. 10 var ( 11 // consecutiveRenewalsBeforeReplacement is the number of times a contract 12 // attempt to be renewed before it is marked as !goodForRenew. 13 consecutiveRenewalsBeforeReplacement = build.Select(build.Var{ 14 Dev: types.BlockHeight(12), 15 Standard: types.BlockHeight(12), // ~2h 16 Testing: types.BlockHeight(12), 17 }).(types.BlockHeight) 18 19 // fileContractMinimumFunding is the lowest percentage of an allowace (on a 20 // per-contract basis) that is allowed to go into funding a contract. If the 21 // allowance is 100 SC per contract (5,000 SC total for 50 contracts, or 22 // 2,000 SC total for 20 contracts, etc.), then the minimum amount of funds 23 // that a contract would be allowed to have is fileContractMinimumFunding * 24 // 100SC. 25 fileContractMinimumFunding = float64(0.15) 26 27 // MinContractFundRenewalThreshold defines the ratio of remaining funds to 28 // total contract cost below which the contractor will prematurely renew a 29 // contract. 30 // 31 // This number is deliberately a little higher than the 32 // minContractFundUploadThreshold because we want to make sure that renewals 33 // will kick in before uploading stops. 34 MinContractFundRenewalThreshold = float64(0.06) // 6% 35 36 // minContractFundUploadThreshold is the percentage of contract funds 37 // remaining at which the contract gets marked !GoodForUpload. The number is 38 // high so that there is plenty of money available for downloading, so that 39 // urgent repairs can be performed and also so that user file access is not 40 // interrupted until after uploading progress is interrupted. Structuring 41 // things this way essentially allows the user to experience the failure 42 // mode of 'can't store additional stuff' before the user experiences the 43 // failure mode of 'can't retrieve stuff already uploaded'. 44 MinContractFundUploadThreshold = float64(0.05) // 5% 45 46 // randomHostsBufferForScore defines how many extra hosts are queried when trying 47 // to figure out an appropriate minimum score for the hosts that we have. 48 randomHostsBufferForScore = build.Select(build.Var{ 49 Dev: 2, 50 Standard: 50, 51 Testing: 1, 52 }).(int) 53 54 // oosRetryInterval is the time we wait for a host that ran out of storage to 55 // add more storage before trying to upload to it again. 56 oosRetryInterval = build.Select(build.Var{ 57 Dev: types.BlockHeight(types.BlocksPerHour / 2), // 30 minutes 58 Standard: types.BlockHeight(types.BlocksPerWeek), // 7 days 59 Testing: types.BlockHeight(types.BlocksPerHour * 2), 60 }).(types.BlockHeight) 61 ) 62 63 // Constants related to the safety values for when the contractor is forming 64 // contracts. 65 var ( 66 maxCollateral = types.SiacoinPrecision.Mul64(60e3) // 60 KS 67 maxStoragePrice = build.Select(build.Var{ 68 Dev: types.SiacoinPrecision.Mul64(1e6).Div(modules.BlockBytesPerMonthTerabyte), // 1 order of magnitude greater 69 Standard: types.SiacoinPrecision.Mul64(100e3).Div(modules.BlockBytesPerMonthTerabyte), // 100KS / TB / Month 70 Testing: types.SiacoinPrecision.Mul64(1e7).Div(modules.BlockBytesPerMonthTerabyte), // 2 orders of magnitude greater 71 }).(types.Currency) 72 maxUploadPrice = build.Select(build.Var{ 73 Dev: maxStoragePrice.Mul64(30 * 4320), // 1 order of magnitude greater 74 Standard: maxStoragePrice.Mul64(3 * 4320), // 3 months of storage 75 Testing: maxStoragePrice.Mul64(300 * 4320), // 2 orders of magnitude greater 76 }).(types.Currency) 77 maxDownloadPrice = maxStoragePrice.Mul64(3 * 4320) 78 79 // scoreLeewayGoodForRenew defines the factor by which a host can miss the 80 // goal score for a set of hosts and still be GoodForRenew. To determine the 81 // goal score, a new set of hosts is queried from the hostdb and the lowest 82 // scoring among them is selected. That score is then divided by 83 // scoreLeewayGoodForRenew to get the minimum score that a host is allowed 84 // to have before being marked as !GoodForRenew. 85 // 86 // TODO: At this point in time, this value is somewhat arbitrary and could 87 // be getting set in a lot more scientific way. 88 scoreLeewayGoodForRenew = types.NewCurrency64(500) 89 90 // scoreLeewayGoodForUpload defines the factor by which a host can miss the 91 // goal score for a set of hosts and still be GoodForUpload. To determine the 92 // goal score, a new set of hosts is queried from the hostdb and the lowest 93 // scoring among them is selected. That score is then divided by 94 // scoreLeewayGoodForUpload to get the minimum score that a host is allowed 95 // to have before being marked as !GoodForUpload. 96 // 97 // Hosts are marked !GoodForUpload before they are marked !GoodForRenew 98 // because churn can harm the health and scalability of a user's filesystem. 99 // Switching away from adding new files to a host can minimize the damage of 100 // using a bad host without incurring data churn. 101 // 102 // TODO: At this point in time, this value is somewhat arbitrary and could 103 // be getting set in a lot more scientific way. 104 scoreLeewayGoodForUpload = types.NewCurrency64(40) 105 )