gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/host/contractmanager/consts.go (about) 1 package contractmanager 2 3 import ( 4 "time" 5 6 "gitlab.com/SiaPrime/SiaPrime/build" 7 "gitlab.com/SiaPrime/SiaPrime/persist" 8 ) 9 10 const ( 11 // logFile is the name of the file that is used for logging in the contract 12 // manager. 13 logFile = "contractmanager.log" 14 15 // metadataFile is the name of the file that stores all of the sector 16 // metadata associated with a storage folder. 17 metadataFile = "siahostmetadata.dat" 18 19 // sectorFile is the file that is placed inside of a storage folder to 20 // house all of the sectors associated with a storage folder. 21 sectorFile = "siahostdata.dat" 22 23 // settingsFile is the name of the file that is used to save the contract 24 // manager's settings. 25 settingsFile = "contractmanager.json" 26 27 // settingsFileTmp is the name of the file that is used to hold unfinished 28 // writes to the contract manager's settings. After this file is completed, 29 // a copy-on-write operation is performed to make sure that the contract 30 // manager's persistent settings are updated atomically. 31 settingsFileTmp = "contractmanager.json_temp" 32 33 // walFile is the name of the file that is used to save the write ahead log 34 // for the contract manager. 35 walFile = "contractmanager.wal" 36 37 // walFileTmp is used for incomplete writes to the WAL. Data could be 38 // interrupted by power outages, etc., and is therefore written to a 39 // temporary file before being atomically renamed to the correct name. 40 walFileTmp = "contractmanager.wal_temp" 41 ) 42 43 const ( 44 // folderAllocationStepSize is the amount of data that gets allocated at a 45 // time when writing out the sparse sector file during a storageFolderAdd or 46 // a storageFolderGrow. 47 folderAllocationStepSize = 1 << 35 48 49 // maxSectorBatchThreads is the maximum number of threads updating 50 // sector counters on disk in AddSectorBatch and RemoveSectorBatch. 51 maxSectorBatchThreads = 100 52 53 // sectorMetadataDiskSize defines the number of bytes it takes to store the 54 // metadata of a single sector on disk. 55 sectorMetadataDiskSize = 14 56 57 // storageFolderGranularity defines the number of sectors that a storage 58 // folder must cleanly divide into. 64 sectors is a requirement due to the 59 // way the storage folder bitfield (field 'Usage') is constructed - the 60 // bitfield defines which sectors are available, and the bitfield must be 61 // constructed 1 uint64 at a time (8 bytes, 64 bits, or 64 sectors). 62 // 63 // This corresponds to a granularity of 256 MiB on the production network, 64 // which is a high granluarity relative the to the TiBs of storage that 65 // hosts are expected to provide. 66 storageFolderGranularity = 64 67 ) 68 69 var ( 70 // settingsMetadata is the header that is used when writing the contract 71 // manager's settings to disk. 72 settingsMetadata = persist.Metadata{ 73 Header: "Sia Contract Manager", 74 Version: "1.2.0", 75 } 76 77 // walMetadata is the header that is used when writing the write ahead log 78 // to disk, so that it may be identified at startup. 79 walMetadata = persist.Metadata{ 80 Header: "Sia Contract Manager WAL", 81 Version: "1.2.0", 82 } 83 ) 84 85 var ( 86 // MaximumSectorsPerStorageFolder sets an upper bound on how large storage 87 // folders in the host are allowed to be. There is a hard limit at 4 88 // billion sectors because the sector location map only uses 4 bytes to 89 // indicate the location of a sector. 90 MaximumSectorsPerStorageFolder = build.Select(build.Var{ 91 Dev: uint64(1 << 20), // 256 GiB 92 Standard: uint64(1 << 32), // 16 PiB 93 Testing: uint64(1 << 12), // 16 MiB 94 }).(uint64) 95 96 // maximumStorageFolders defines the maximum number of storage folders that 97 // the host can support. 98 maximumStorageFolders = build.Select(build.Var{ 99 Dev: uint64(1 << 5), 100 Standard: uint64(1 << 16), 101 Testing: uint64(1 << 3), 102 }).(uint64) 103 104 // MinimumSectorsPerStorageFolder defines the minimum number of sectors 105 // that a storage folder is allowed to have. 106 MinimumSectorsPerStorageFolder = build.Select(build.Var{ 107 Dev: uint64(1 << 6), // 16 MiB 108 Standard: uint64(1 << 6), // 256 MiB 109 Testing: uint64(1 << 6), // 256 KiB 110 }).(uint64) 111 ) 112 113 var ( 114 // folderRecheckInitialInterval specifies the amount of time that the 115 // contract manager will initially wait when checking to see if an 116 // unavailable storage folder has become available. 117 folderRecheckInitialInterval = build.Select(build.Var{ 118 Dev: time.Second, 119 Standard: time.Second * 5, 120 Testing: time.Second, 121 }).(time.Duration) 122 123 // maxFolderRecheckInterval specifies the maximum amount of time that the 124 // contract manager will wait between checking if an unavailable storage 125 // folder has become available. 126 maxFolderRecheckInterval = build.Select(build.Var{ 127 Dev: time.Second * 30, 128 Standard: time.Second * 60 * 5, 129 Testing: time.Second * 8, 130 }).(time.Duration) 131 )