gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/renter/proto/consts.go (about)

     1  package proto
     2  
     3  import (
     4  	"time"
     5  
     6  	"gitlab.com/SiaPrime/SiaPrime/build"
     7  	"gitlab.com/SiaPrime/SiaPrime/crypto"
     8  	"gitlab.com/SiaPrime/SiaPrime/modules"
     9  	"gitlab.com/SiaPrime/SiaPrime/types"
    10  )
    11  
    12  const (
    13  	// contractExtension is the extension given to contract files.
    14  	contractExtension = ".contract"
    15  
    16  	// rootsDiskLoadBulkSize is the max number of roots we read from disk at
    17  	// once to avoid using up all the ram.
    18  	rootsDiskLoadBulkSize = 1024 * crypto.HashSize // 32 kib
    19  
    20  	// remainingFile is a constant used to indicate that a fileSection can access
    21  	// the whole remaining file instead of being bound to a certain end offset.
    22  	remainingFile = -1
    23  
    24  	// keyExchangeMaxLen is the maximum number of bytes the renter will read
    25  	// from the host during the RPC key exchange.
    26  	keyExchangeMaxLen = 256
    27  )
    28  
    29  var (
    30  	// The following specifiers are used for deriving different seeds from the
    31  	// wallet seed.
    32  	identifierSeedSpecifier = types.Specifier{'i', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', 's', 'e', 'e', 'd'}
    33  	renterSeedSpecifier     = types.Specifier{'r', 'e', 'n', 't', 'e', 'r'}
    34  	secretKeySeedSpecifier  = types.Specifier{'s', 'e', 'c', 'r', 'e', 't', 'k', 'e', 'y', 's', 'e', 'e', 'd'}
    35  	signingKeySeedSpecifier = types.Specifier{'s', 'i', 'g', 'n', 'i', 'n', 'g', 'k', 'e', 'y', 's', 'e', 'e', 'd'}
    36  )
    37  
    38  var (
    39  	// connTimeout determines the number of seconds before a dial-up or
    40  	// revision negotiation times out.
    41  	connTimeout = build.Select(build.Var{
    42  		Dev:      10 * time.Second,
    43  		Standard: 2 * time.Minute,
    44  		Testing:  5 * time.Second,
    45  	}).(time.Duration)
    46  
    47  	// defaultContractLockTimeout is the default amount of the time, in
    48  	// milliseconds, that the renter will try to acquire a contract lock for.
    49  	defaultContractLockTimeout = build.Select(build.Var{
    50  		Dev:      uint64(60 * 1000),     // 1 minute
    51  		Standard: uint64(5 * 60 * 1000), // 5 minutes
    52  		Testing:  uint64(5 * 1000),      // 5 seconds
    53  	}).(uint64)
    54  
    55  	// ephemeralSeedInterval is the amount of blocks after which we use a new
    56  	// renter seed for creating file contracts.
    57  	ephemeralSeedInterval = build.Select(build.Var{
    58  		Dev:      types.BlockHeight(100),
    59  		Standard: types.BlockHeight(1000),
    60  		Testing:  types.BlockHeight(10),
    61  	}).(types.BlockHeight)
    62  
    63  	// hostPriceLeeway is the amount of flexibility we give to hosts when
    64  	// choosing how much to pay for file uploads. If the host does not have the
    65  	// most recent block yet, the host will be expecting a slightly larger
    66  	// payment.
    67  	//
    68  	// TODO: Due to the network connectivity issues that v1.3.0 introduced, we
    69  	// had to increase the amount moderately because hosts would not always be
    70  	// properly connected to the peer network, and so could fall behind on
    71  	// blocks. Once enough of the network has upgraded, we can move the number
    72  	// to '0.003' for 'Standard'.
    73  	hostPriceLeeway = build.Select(build.Var{
    74  		Dev:      0.05,
    75  		Standard: 0.01,
    76  		Testing:  0.002,
    77  	}).(float64)
    78  
    79  	// sectorHeight is the height of a Merkle tree that covers a single
    80  	// sector. It is log2(modules.SectorSize / crypto.SegmentSize)
    81  	sectorHeight = func() uint64 {
    82  		height := uint64(0)
    83  		for 1<<height < (modules.SectorSize / crypto.SegmentSize) {
    84  			height++
    85  		}
    86  		return height
    87  	}()
    88  )