gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/renter/proto/consts.go (about)

     1  package proto
     2  
     3  import (
     4  	"time"
     5  
     6  	"gitlab.com/NebulousLabs/errors"
     7  
     8  	"gitlab.com/SkynetLabs/skyd/build"
     9  	"go.sia.tech/siad/crypto"
    10  	"go.sia.tech/siad/modules"
    11  )
    12  
    13  const (
    14  	// v146ContractExtension is the extension given to contract files pre v147.
    15  	v146ContractExtension = ".contract"
    16  
    17  	// contractHeaderExtension is the extension given to the header file of a
    18  	// contract.
    19  	contractHeaderExtension = ".header"
    20  
    21  	// contractRootsExtension is the extension given to the file that contains
    22  	// the contract's roots.
    23  	contractRootsExtension = ".roots"
    24  
    25  	// refCounterExtension is the extension given to reference counter files.
    26  	refCounterExtension = ".rc"
    27  
    28  	// rootsDiskLoadBulkSize is the max number of roots we read from disk at
    29  	// once to avoid using up all the ram.
    30  	rootsDiskLoadBulkSize = 1 << 16 * crypto.HashSize // 2 MiB
    31  
    32  	// remainingFile is a constant used to indicate that a fileSection can access
    33  	// the whole remaining file instead of being bound to a certain end offset.
    34  	remainingFile = -1
    35  )
    36  
    37  var (
    38  	// connTimeout determines the number of seconds before a dial-up or
    39  	// revision negotiation times out.
    40  	connTimeout = build.Select(build.Var{
    41  		Dev:      10 * time.Second,
    42  		Standard: 2 * time.Minute,
    43  		Testing:  5 * time.Second,
    44  	}).(time.Duration)
    45  
    46  	// defaultContractLockTimeout is the default amount of the time, in
    47  	// milliseconds, that the renter will try to acquire a contract lock for.
    48  	defaultContractLockTimeout = build.Select(build.Var{
    49  		Dev:      uint64(60 * 1000),     // 1 minute
    50  		Standard: uint64(5 * 60 * 1000), // 5 minutes
    51  		Testing:  uint64(25 * 1000),     // 25 seconds
    52  	}).(uint64)
    53  
    54  	// hostPriceLeeway is the amount of flexibility we give to hosts when
    55  	// choosing how much to pay for file uploads. If the host does not have the
    56  	// most recent block yet, the host will be expecting a slightly larger
    57  	// payment.
    58  	//
    59  	// TODO: Due to the network connectivity issues that v1.3.0 introduced, we
    60  	// had to increase the amount moderately because hosts would not always be
    61  	// properly connected to the peer network, and so could fall behind on
    62  	// blocks. Once enough of the network has upgraded, we can move the number
    63  	// to '0.003' for 'Standard'.
    64  	hostPriceLeeway = build.Select(build.Var{
    65  		Dev:      0.05,
    66  		Standard: 0.01,
    67  		Testing:  0.002,
    68  	}).(float64)
    69  
    70  	// sectorHeight is the height of a Merkle tree that covers a single
    71  	// sector. It is log2(modules.SectorSize / crypto.SegmentSize)
    72  	sectorHeight = func() uint64 {
    73  		height := uint64(0)
    74  		for 1<<height < (modules.SectorSize / crypto.SegmentSize) {
    75  			height++
    76  		}
    77  		return height
    78  	}()
    79  )
    80  
    81  var (
    82  	// ErrBadHostVersion indicates that the host is using an older, incompatible
    83  	// version of the renter-host protocol.
    84  	ErrBadHostVersion = errors.New("Bad host version; host does not support required protocols")
    85  )