github.com/johnathanhowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/modules/host/storagemanager/consts.go (about) 1 package storagemanager 2 3 import ( 4 "github.com/NebulousLabs/Sia/build" 5 ) 6 7 const ( 8 // maximumStorageFolders indicates the maximum number of storage folders 9 // that the host allows. Some operations, such as creating a new storage 10 // folder, take longer if there are more storage folders. Static RAM usage 11 // also increases as the number of storage folders increase. For this 12 // reason, a limit on the maximum number of storage folders has been set. 13 maximumStorageFolders = 100 14 ) 15 16 var ( 17 // maximumStorageFolderSize sets an upper bound on how large storage 18 // folders in the host are allowed to be. It makes sure that inputs and 19 // constructions are sane. While it's conceivable that someone could create 20 // a rig with a single logical storage folder greater than 128 TiB in size 21 // in production, it's probably not a great idea, especially when you are 22 // allowed to use many storage folders. All told, a single host on today's 23 // constants can support up to ~10 PB of storage. 24 maximumStorageFolderSize = func() uint64 { 25 if build.Release == "dev" { 26 return 1 << 40 // 1 TiB 27 } 28 if build.Release == "standard" { 29 return 1 << 50 // 1 PiB 30 } 31 if build.Release == "testing" { 32 return 1 << 20 // 1 MiB 33 } 34 panic("unrecognized release constant in host - maximum storage folder size") 35 }() 36 37 // maximumVirtualSectors defines the maximum number of virtual sectors that 38 // can be tied to each physical sector. 39 maximumVirtualSectors = func() int { 40 if build.Release == "dev" { 41 // The testing value is at 35 to provide flexibility. The 42 // development value is at 5 because hitting the virtual sector 43 // limit in a sane development environment is more difficult than 44 // hitting the virtual sector limit in a controlled testing 45 // environment (dev environment doesn't have access to private 46 // methods such as 'addSector'. 47 return 5 48 } 49 if build.Release == "standard" { 50 // Each virtual sector adds about 8 bytes of load to the host 51 // persistence structures, and additionally adds 8 bytes of load 52 // when reading or modifying a sector. Though a few virtual sectors 53 // with 10e3 or even 100e3 virtual sectors would not be too 54 // detrimental to the host, tens of thousands of physical sectors 55 // that each have ten thousand virtual sectors could pose a problem 56 // for the host. In most situations, a renter will not need more 2 57 // or 3 virtual sectors when manipulating data, so 250 is generous 58 // as long as the renter is properly encrypting data. 250 is 59 // unlikely to cause the host problems, even if an attacker is 60 // creating hundreds of thousands of phsyical sectors (an expensive 61 // action!) each with 250 vitrual sectors. 62 return 250 63 } 64 if build.Release == "testing" { 65 return 35 66 } 67 panic("unrecognized release constant in host - maximum virtual sector size") 68 }() 69 70 // minimumStorageFolderSize defines the smallest size that a storage folder 71 // is allowed to be. The new design of the storage folder structure means 72 // that this limit is not as relevant as it was originally, but hosts with 73 // little storage capacity are not very useful to the network, and can 74 // actually frustrate price planning. 32 GB has been chosen as a minimum 75 // for the early days of the network, to allow people to experiment in the 76 // beta, but in the future I think something like 256GB would be much more 77 // appropriate. 78 minimumStorageFolderSize = func() uint64 { 79 if build.Release == "dev" { 80 return 1 << 25 // 32 MiB 81 } 82 if build.Release == "standard" { 83 return 1 << 35 // 32 GiB 84 } 85 if build.Release == "testing" { 86 return 1 << 15 // 32 KiB 87 } 88 panic("unrecognized release constant in host - minimum storage folder size") 89 }() 90 91 // storageFolderUIDSize determines the number of bytes used to determine 92 // the storage folder UID. Production and development environments use 4 93 // bytes to minimize the possibility of accidental collisions, and testing 94 // environments use 1 byte so that collisions can be forced while using the 95 // live code. 96 storageFolderUIDSize = func() int { 97 if build.Release == "dev" { 98 return 2 99 } 100 if build.Release == "standard" { 101 return 4 102 } 103 if build.Release == "testing" { 104 return 1 105 } 106 panic("unrecognized release constant in host - storageFolderUIDSize") 107 }() 108 109 // bucketSectorUsage maps sector IDs to the number of times they are used 110 // in file contracts. If all data is correctly encrypted using a unique 111 // seed, each sector will be in use exactly one time. The host however 112 // cannot control this, and a user may upload unencrypted data or 113 // intentionally upload colliding sectors as a means of attack. The host 114 // can only delete a sector when it is in use zero times. The number of 115 // times a sector is in use is encoded as a big endian uint64. 116 bucketSectorUsage = []byte("BucketSectorUsage") 117 )