contractmanager

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 = build.Select(build.Var{
		Dev:      uint64(1 << 20),
		Standard: uint64(1 << 32),
		Testing:  uint64(1 << 12),
	}).(uint64)

	// MinimumSectorsPerStorageFolder defines the minimum number of sectors
	// that a storage folder is allowed to have.
	MinimumSectorsPerStorageFolder = build.Select(build.Var{
		Dev:      uint64(1 << 6),
		Standard: uint64(1 << 6),
		Testing:  uint64(1 << 6),
	}).(uint64)
)
View Source
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)
)
View Source
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")
)
View Source
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 New

func New(persistDir string) (*ContractManager, error)

New returns a new ContractManager.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL