Documentation ¶
Index ¶
- Variables
- type ContractManager
- func (cm *ContractManager) AddSector(root crypto.Hash, sectorData []byte) error
- func (cm *ContractManager) AddSectorBatch(sectorRoots []crypto.Hash) error
- func (cm *ContractManager) AddStorageFolder(path string, size uint64) error
- func (cm *ContractManager) Close() error
- func (cm *ContractManager) DeleteSector(root crypto.Hash) error
- func (cm *ContractManager) ReadSector(root crypto.Hash) ([]byte, error)
- func (cm *ContractManager) RemoveSector(root crypto.Hash) error
- func (cm *ContractManager) RemoveSectorBatch(sectorRoots []crypto.Hash) error
- func (cm *ContractManager) RemoveStorageFolder(index uint16, force bool) error
- func (cm *ContractManager) ResetStorageFolderHealth(index uint16) error
- func (cm *ContractManager) ResizeStorageFolder(index uint16, newSize uint64, force bool) error
- func (cm *ContractManager) StorageFolders() []modules.StorageFolderMetadata
Constants ¶
This section is empty.
Variables ¶
var ( // MaximumSectorsPerStorageFolder sets an upper bound on how large storage // folders in the host are allowed to be. There is a hard limit at 4 // billion sectors because the sector location map only uses 4 bytes to // indicate the location of a sector. MaximumSectorsPerStorageFolder = func() uint64 { if build.Release == "dev" { return 1 << 20 } if build.Release == "standard" { return 1 << 25 } if build.Release == "testing" { return 1 << 12 } panic("unrecognized release constant in host - maximum storage folder size") }() // MinimumSectorsPerStorageFolder defines the minimum number of sectors // that a storage folder is allowed to have. MinimumSectorsPerStorageFolder = func() uint64 { if build.Release == "dev" { return 1 << 6 } if build.Release == "standard" { return 1 << 6 } if build.Release == "testing" { return 1 << 6 } panic("unrecognized release constant in host - minimum storage folder size") }() )
var ( // ErrLargeStorageFolder is returned if a new storage folder or a resized // storage folder would exceed the maximum allowed size. ErrLargeStorageFolder = fmt.Errorf("maximum allowed size for a storage folder is %v bytes", MaximumSectorsPerStorageFolder*modules.SectorSize) // ErrNoResize is returned if a new size is provided for a storage folder // that is the same as the current size of the storage folder. ErrNoResize = errors.New("storage folder selected for resize, but new size is same as current size") // ErrRepeatFolder is returned if a storage folder is added which links to // a path that is already in use by another storage folder. Only exact path // matches will trigger the error. ErrRepeatFolder = errors.New("selected path is already in use as a storage folder, please use 'resize'") // ErrSmallStorageFolder is returned if a new storage folder is not large // enough to meet the requirements for the minimum storage folder size. ErrSmallStorageFolder = fmt.Errorf("minimum allowed size for a storage folder is %v bytes", MinimumSectorsPerStorageFolder*modules.SectorSize) )
var ( // ErrPartialRelocation is returned during an operation attempting to clear // out the sectors in a storage folder if errors prevented one or more of // the sectors from being properly migrated to a new storage folder. ErrPartialRelocation = errors.New("unable to migrate all sectors") )
var ( // ErrSectorNotFound is returned when a lookup for a sector fails. ErrSectorNotFound = errors.New("could not find the desired sector") )
Functions ¶
This section is empty.
Types ¶
type ContractManager ¶
type ContractManager struct {
// contains filtered or unexported fields
}
ContractManager is responsible for managing contracts that the host has with renters, including storing the data, submitting storage proofs, and deleting the data when a contract is complete.
func (*ContractManager) AddSector ¶
func (cm *ContractManager) AddSector(root crypto.Hash, sectorData []byte) error
AddSector will add a sector to the contract manager.
func (*ContractManager) AddSectorBatch ¶
func (cm *ContractManager) AddSectorBatch(sectorRoots []crypto.Hash) error
AddSectorBatch is a non-ACID call to add a bunch of sectors at once. Necessary for compatibility with old renters.
TODO: Make ACID, and definitely improve the performance as well.
func (*ContractManager) AddStorageFolder ¶
func (cm *ContractManager) AddStorageFolder(path string, size uint64) error
AddStorageFolder adds a storage folder to the contract manager.
func (*ContractManager) Close ¶
func (cm *ContractManager) Close() error
Close will cleanly shutdown the contract manager.
func (*ContractManager) DeleteSector ¶
func (cm *ContractManager) DeleteSector(root crypto.Hash) error
DeleteSector will delete a sector from the contract manager. If multiple copies of the sector exist, all of them will be removed. This should only be used to remove offensive data, as it will cause corruption in the contract manager. This corruption puts the contract manager at risk of failing storage proofs. If the amount of data removed is small, the risk is small. This operation will not destabilize the contract manager.
func (*ContractManager) ReadSector ¶
func (cm *ContractManager) ReadSector(root crypto.Hash) ([]byte, error)
ReadSector will read a sector from the storage manager, returning the bytes that match the input sector root.
func (*ContractManager) RemoveSector ¶
func (cm *ContractManager) RemoveSector(root crypto.Hash) error
RemoveSector will remove a sector from the contract manager. If multiple copies of the sector exist, only one will be removed.
func (*ContractManager) RemoveSectorBatch ¶
func (cm *ContractManager) RemoveSectorBatch(sectorRoots []crypto.Hash) error
RemoveSectorBatch is a non-ACID call to remove a bunch of sectors at once. Necessary for compatibility with old renters.
TODO: Make ACID, and definitely improve the performance as well.
func (*ContractManager) RemoveStorageFolder ¶
func (cm *ContractManager) RemoveStorageFolder(index uint16, force bool) error
RemoveStorageFolder will delete a storage folder from the contract manager, moving all of the sectors in the storage folder to new storage folders.
func (*ContractManager) ResetStorageFolderHealth ¶
func (cm *ContractManager) ResetStorageFolderHealth(index uint16) error
ResetStorageFolderHealth will reset the read and write statistics for the input storage folder.
func (*ContractManager) ResizeStorageFolder ¶
func (cm *ContractManager) ResizeStorageFolder(index uint16, newSize uint64, force bool) error
ResizeStorageFolder will resize a storage folder, moving sectors as necessary. The resize operation will stop and return an error if any of the sector move operations fail. If the force flag is set to true, the resize operation will continue through failures, meaning that data will be lost.
func (*ContractManager) StorageFolders ¶
func (cm *ContractManager) StorageFolders() []modules.StorageFolderMetadata
StorageFolders will return a list of storage folders in the host, each containing information about the storage folder and any operations currently being executed on the storage folder.