gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/renter/siafile/consts.go (about) 1 package siafile 2 3 import ( 4 "gitlab.com/SiaPrime/writeaheadlog" 5 6 "gitlab.com/SiaPrime/SiaPrime/crypto" 7 "gitlab.com/SiaPrime/SiaPrime/modules" 8 ) 9 10 const ( 11 // pageSize is the size of a physical page on disk. 12 pageSize = 4096 13 14 // defaultReservedMDPages is the number of pages we reserve for the 15 // metadata when we create a new siaFile. Should the metadata ever grow 16 // larger than that, new pages are added on demand. 17 defaultReservedMDPages = 1 18 19 // updateInsertName is the name of a siaFile update that inserts data at a specific index. 20 updateInsertName = "SiaFileInsert" 21 22 // updateDeleteName is the name of a siaFile update that deletes the 23 // specified file. 24 updateDeleteName = "SiaFileDelete" 25 26 // updateDeletePartialName is the name of a wal update that deletes the 27 // specified file. 28 updateDeletePartialName = "PartialChunkDelete" 29 30 // marshaledPieceSize is the size of a piece on disk. It consists of a 4 31 // byte pieceIndex, a 4 byte table offset and a hash. 32 marshaledPieceSize = 4 + 4 + crypto.HashSize 33 34 // marshaledChunkOverhead is the size of a marshaled chunk on disk minus the 35 // encoded pieces. It consists of the 16 byte extension info, a 2 byte 36 // length prefix for the pieces, and a 1 byte length for the Stuck field. 37 marshaledChunkOverhead = 16 + 2 + 1 38 39 // pubKeyTablePruneThreshold is the number of unused hosts a SiaFile can 40 // store in its host key table before it is pruned. 41 pubKeyTablePruneThreshold = 50 42 43 // threadDepth is how deep the ThreadType will track calling files and 44 // calling lines 45 threadDepth = 3 46 47 // fileListRoutines is the number of goroutines used in FileList to load 48 // siafile metadata from disk 49 fileListRoutines = 20 50 ) 51 52 // Constants to indicate which part of the partial upload the combined chunk is 53 // currently at. 54 const ( 55 CombinedChunkStatusInvalid = iota // status wasn't initialized 56 CombinedChunkStatusInComplete // partial chunk is included in an incomplete combined chunk. 57 CombinedChunkStatusCompleted // partial chunk is included in a completed combined chunk. 58 ) 59 60 var ( 61 // ecReedSolomon is the marshaled type of the reed solomon coder. 62 ecReedSolomon = modules.ErasureCoderType{0, 0, 0, 1} 63 64 // ecReedSolomonSubShards64 is the marshaled type of the reed solomon coder 65 // for files where every 64 bytes of an encoded piece can be decoded 66 // separately. 67 ecReedSolomonSubShards64 = modules.ErasureCoderType{0, 0, 0, 2} 68 ) 69 70 // marshaledChunkSize is a helper method that returns the size of a chunk on 71 // disk given the number of pieces the chunk contains. 72 func marshaledChunkSize(numPieces int) int64 { 73 return marshaledChunkOverhead + marshaledPieceSize*int64(numPieces) 74 } 75 76 // IsSiaFileUpdate is a helper method that makes sure that a wal update belongs 77 // to the SiaFile package. 78 func IsSiaFileUpdate(update writeaheadlog.Update) bool { 79 switch update.Name { 80 case updateInsertName, updateDeleteName, updateDeletePartialName: 81 return true 82 default: 83 return false 84 } 85 }