gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/renter/filesystem/siafile/consts.go (about)

     1  package siafile
     2  
     3  import (
     4  	"gitlab.com/NebulousLabs/writeaheadlog"
     5  
     6  	"go.sia.tech/siad/crypto"
     7  )
     8  
     9  const (
    10  	// pageSize is the size of a physical page on disk.
    11  	pageSize = 4096
    12  
    13  	// defaultReservedMDPages is the number of pages we reserve for the
    14  	// metadata when we create a new siaFile. Should the metadata ever grow
    15  	// larger than that, new pages are added on demand.
    16  	defaultReservedMDPages = 1
    17  
    18  	// updateInsertName is the name of a siaFile update that inserts data at a specific index.
    19  	updateInsertName = "SiaFileInsert"
    20  
    21  	// updateDeleteName is the name of a siaFile update that deletes the
    22  	// specified file.
    23  	updateDeleteName = "SiaFileDelete"
    24  
    25  	// updateDeletePartialName is the name of a wal update that deletes the
    26  	// specified file.
    27  	updateDeletePartialName = "PartialChunkDelete"
    28  
    29  	// marshaledPieceSize is the size of a piece on disk. It consists of a 4
    30  	// byte pieceIndex, a 4 byte table offset and a hash.
    31  	marshaledPieceSize = 4 + 4 + crypto.HashSize
    32  
    33  	// marshaledChunkOverhead is the size of a marshaled chunk on disk minus the
    34  	// encoded pieces. It consists of the 16 byte extension info, a 2 byte
    35  	// length prefix for the pieces, and a 1 byte length for the Stuck field.
    36  	marshaledChunkOverhead = 16 + 2 + 1
    37  
    38  	// pubKeyTablePruneThreshold is the number of unused hosts a SiaFile can
    39  	// store in its host key table after a prune.
    40  	pubKeyTableLowerPruneThreshold = 50
    41  
    42  	// pubKeyTableUpperPruneThreshold is the number of unused hosts a
    43  	// SiaFile can store in its host key table before a prune is triggered.
    44  	pubKeyTableUpperPruneThreshold = 100
    45  )
    46  
    47  // Constants to indicate which part of the partial upload the combined chunk is
    48  // currently at.
    49  const (
    50  	CombinedChunkStatusInvalid    = iota // status wasn't initialized
    51  	CombinedChunkStatusInComplete        // partial chunk is included in an incomplete combined chunk.
    52  	CombinedChunkStatusCompleted         // partial chunk is included in a completed combined chunk.
    53  )
    54  
    55  // marshaledChunkSize is a helper method that returns the size of a chunk on
    56  // disk given the number of pieces the chunk contains.
    57  func marshaledChunkSize(numPieces int) int64 {
    58  	return marshaledChunkOverhead + marshaledPieceSize*int64(numPieces)
    59  }
    60  
    61  // IsSiaFileUpdate is a helper method that makes sure that a wal update belongs
    62  // to the SiaFile package.
    63  func IsSiaFileUpdate(update writeaheadlog.Update) bool {
    64  	switch update.Name {
    65  	case updateInsertName, updateDeleteName, updateDeletePartialName:
    66  		return true
    67  	default:
    68  		return false
    69  	}
    70  }