Commit 5deb7661 authored by Luke Champine's avatar Luke Champine

give hosts more price leeway during dev

parent befc00a3
......@@ -5,6 +5,7 @@ import (
"net"
"time"
"github.com/NebulousLabs/Sia/build"
"github.com/NebulousLabs/Sia/crypto"
"github.com/NebulousLabs/Sia/encoding"
"github.com/NebulousLabs/Sia/modules"
......@@ -32,6 +33,12 @@ func (hd *Downloader) Sector(root crypto.Hash) (modules.RenterContract, []byte,
if hd.contract.RenterFunds().Cmp(sectorPrice) < 0 {
return modules.RenterContract{}, nil, errors.New("contract has insufficient funds to support download")
}
// to mitigate small errors (e.g. differing block heights), fudge the
// price and collateral by 0.2%. This is only applied to hosts above
// v1.0.1; older hosts use stricter math.
if build.VersionCmp(hd.host.Version, "1.0.1") > 0 {
sectorPrice = sectorPrice.MulFloat(1 + hostPriceLeeway)
}
// create the download revision
rev := newDownloadRevision(hd.contract.LastRevision, sectorPrice)
......
......@@ -12,6 +12,12 @@ import (
"github.com/NebulousLabs/Sia/types"
)
var hostPriceLeeway = build.Select(build.Var{
Dev: 0.05,
Standard: 0.002,
Testing: 0.002,
}).(float64)
var (
// sectorHeight is the height of a Merkle tree that covers a single
// sector. It is log2(modules.SectorSize / crypto.SegmentSize)
......@@ -115,9 +121,9 @@ func (he *Editor) Upload(data []byte) (modules.RenterContract, crypto.Hash, erro
// price and collateral by 0.2%. This is only applied to hosts above
// v1.0.1; older hosts use stricter math.
if build.VersionCmp(he.host.Version, "1.0.1") > 0 {
sectorStoragePrice = sectorStoragePrice.MulFloat(1.002)
sectorBandwidthPrice = sectorBandwidthPrice.MulFloat(1.002)
sectorCollateral = sectorCollateral.MulFloat(0.998)
sectorStoragePrice = sectorStoragePrice.MulFloat(1 + hostPriceLeeway)
sectorBandwidthPrice = sectorBandwidthPrice.MulFloat(1 + hostPriceLeeway)
sectorCollateral = sectorCollateral.MulFloat(1 - hostPriceLeeway)
}
sectorPrice := sectorStoragePrice.Add(sectorBandwidthPrice)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment