gitlab.com/jokerrs1/Sia@v1.3.2/modules/renter/consts.go (about)

     1  package renter
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/NebulousLabs/Sia/build"
     7  	"github.com/NebulousLabs/Sia/crypto"
     8  	"github.com/NebulousLabs/Sia/modules"
     9  )
    10  
    11  var (
    12  	// defaultMemory establishes the default amount of memory that the renter
    13  	// will use when performing uploads and downloads. The mapping is currently
    14  	// not perfect due to GC overhead and other places where we don't count all
    15  	// of the memory usage accurately.
    16  	defaultMemory = build.Select(build.Var{
    17  		Dev:      uint64(1 << 28),     // 256 MiB
    18  		Standard: uint64(3 * 1 << 28), // 768 MiB
    19  		Testing:  uint64(1 << 17),     // 128 KiB - 4 KiB sector size, need to test memory exhaustion
    20  	}).(uint64)
    21  )
    22  
    23  var (
    24  	// defaultDataPieces is the number of data pieces per erasure-coded chunk
    25  	defaultDataPieces = func() int {
    26  		switch build.Release {
    27  		case "dev":
    28  			return 1
    29  		case "standard":
    30  			return 10
    31  		case "testing":
    32  			return 1
    33  		}
    34  		panic("undefined defaultDataPieces")
    35  	}()
    36  
    37  	// defaultParityPieces is the number of parity pieces per erasure-coded
    38  	// chunk
    39  	defaultParityPieces = func() int {
    40  		switch build.Release {
    41  		case "dev":
    42  			return 1
    43  		case "standard":
    44  			return 20
    45  		case "testing":
    46  			return 8
    47  		}
    48  		panic("undefined defaultParityPieces")
    49  	}()
    50  
    51  	// Erasure-coded piece size
    52  	pieceSize = modules.SectorSize - crypto.TwofishOverhead
    53  )
    54  
    55  const (
    56  	// defaultFilePerm defines the default permissions used for a new file if no
    57  	// permissions are supplied.
    58  	defaultFilePerm = 0666
    59  
    60  	// downloadFailureCooldown defines how long to wait for a worker after a
    61  	// worker has experienced a download failure.
    62  	downloadFailureCooldown = time.Second * 3
    63  
    64  	// memoryPriorityLow is used to request low priority memory
    65  	memoryPriorityLow = false
    66  
    67  	// memoryPriorityHigh is used to request high priority memory
    68  	memoryPriorityHigh = true
    69  )
    70  
    71  var (
    72  	// chunkDownloadTimeout defines the maximum amount of time to wait for a
    73  	// chunk download to finish before returning in the download-to-upload repair
    74  	// loop
    75  	chunkDownloadTimeout = build.Select(build.Var{
    76  		Dev:      15 * time.Minute,
    77  		Standard: 15 * time.Minute,
    78  		Testing:  1 * time.Minute,
    79  	}).(time.Duration)
    80  
    81  	// maxConsecutivePenalty determines how many times the timeout/cooldown for
    82  	// being a bad host can be doubled before a maximum cooldown is reached.
    83  	maxConsecutivePenalty = build.Select(build.Var{
    84  		Dev:      4,
    85  		Standard: 10,
    86  		Testing:  3,
    87  	}).(int)
    88  
    89  	// maxScheduledDownloads specifies the number of chunks that can be downloaded
    90  	// for auto repair at once. If the limit is reached new ones will only be scheduled
    91  	// once old ones are scheduled for upload
    92  	maxScheduledDownloads = build.Select(build.Var{
    93  		Dev:      5,
    94  		Standard: 10,
    95  		Testing:  5,
    96  	}).(int)
    97  
    98  	// offlineCheckFrequency is how long the renter will wait to check the
    99  	// online status if it is offline.
   100  	offlineCheckFrequency = build.Select(build.Var{
   101  		Dev:      3 * time.Second,
   102  		Standard: 10 * time.Second,
   103  		Testing:  250 * time.Millisecond,
   104  	}).(time.Duration)
   105  
   106  	// rebuildChunkHeapInterval defines how long the renter sleeps between
   107  	// checking on the filesystem health.
   108  	rebuildChunkHeapInterval = build.Select(build.Var{
   109  		Dev:      90 * time.Second,
   110  		Standard: 15 * time.Minute,
   111  		Testing:  3 * time.Second,
   112  	}).(time.Duration)
   113  
   114  	// Prime to avoid intersecting with regular events.
   115  	uploadFailureCooldown = build.Select(build.Var{
   116  		Dev:      time.Second * 7,
   117  		Standard: time.Second * 61,
   118  		Testing:  time.Second,
   119  	}).(time.Duration)
   120  
   121  	// workerPoolUpdateTimeout is the amount of time that can pass before the
   122  	// worker pool should be updated.
   123  	workerPoolUpdateTimeout = build.Select(build.Var{
   124  		Dev:      30 * time.Second,
   125  		Standard: 5 * time.Minute,
   126  		Testing:  3 * time.Second,
   127  	}).(time.Duration)
   128  )