storagemanager

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

package storagemanager implements a storage manager for the host on Sia. The storage manager can add sectors, remove sectors, and manage how sectors are distributed between a number of storage folders.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPath is returned if a path is an empty string or was not
	// provided.
	ErrEmptyPath = errors.New("must provide nonempty path string for storage folder")

	// 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", maximumStorageFolderSize)

	// 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")

	// 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", minimumStorageFolderSize)

	// ErrIncompleteOffload is returned when the host is tasked with offloading
	// sectors from a storage folder but is unable to offload the requested
	// number - but is able to offload some of them.
	ErrIncompleteOffload = errors.New("could not successfully offload specified number of sectors from storage folder")

	// ErrRelativePath is returned if a path must be absolute.
	ErrRelativePath = errors.New("storage folder paths must be absolute")

	// 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'")
)
View Source
var (
	// ErrSectorNotFound is returned when a lookup for a sector fails.
	ErrSectorNotFound = errors.New("could not find the desired sector")
)

Functions

func MaximumStorageFolderSize added in v1.0.3

func MaximumStorageFolderSize() uint64

MaximumStorageFolderSize provides the maximumStorageFolderSize value to other modules for testing purposes.

func MinimumStorageFolderSize added in v1.0.3

func MinimumStorageFolderSize() uint64

MinimumStorageFolderSize provides the minimumStorageFolderSize value to other modules for testing purposes.

Types

type StorageManager

type StorageManager struct {
	// contains filtered or unexported fields
}

StorageManager tracks multiple storage folders, and is responsible for adding sectors, removing sectors, and overall managing the way that data is stored.

func New

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

New returns an initialized StorageManager.

func (*StorageManager) AddSector

func (sm *StorageManager) AddSector(sectorRoot crypto.Hash, expiryHeight types.BlockHeight, sectorData []byte) error

AddSector will add a data sector to the host, correctly selecting the storage folder in which the sector belongs.

func (*StorageManager) AddSectorBatch added in v1.0.3

func (sm *StorageManager) AddSectorBatch(sectorRoots []crypto.Hash, expiryHeight types.BlockHeight) error

AddSectorBatch will add a set of sectors to the host, correctly selecting the storage folders in which the sectors belong. The sectors should all be virtual sectors.

func (*StorageManager) AddStorageFolder

func (sm *StorageManager) AddStorageFolder(path string, size uint64) error

AddStorageFolder adds a storage folder to the host.

func (*StorageManager) Close

func (sm *StorageManager) Close() (composedError error)

Close will shut down the storage manager.

func (*StorageManager) DeleteSector

func (sm *StorageManager) DeleteSector(sectorRoot crypto.Hash) error

DeleteSector deletes a sector from the host explicitly, meaning that the host will be unable to transfer that sector to a renter, and that the host will be unable to perform a storage proof on that sector. This function is not intended to be used, however is available so that hosts can easily comply if compelled by their government to delete certain data.

func (*StorageManager) ReadSector

func (sm *StorageManager) ReadSector(sectorRoot crypto.Hash) (sectorBytes []byte, err error)

ReadSector will pull a sector from disk into memory.

func (*StorageManager) RemoveSector

func (sm *StorageManager) RemoveSector(sectorRoot crypto.Hash, expiryHeight types.BlockHeight) error

RemoveSector will remove a sector from the host at the given expiry height. If the provided sector does not have an expiration at the given height, an error will be thrown.

func (*StorageManager) RemoveStorageFolder

func (sm *StorageManager) RemoveStorageFolder(removalIndex int, force bool) error

RemoveStorageFolder removes a storage folder from the host.

func (*StorageManager) ResetStorageFolderHealth

func (sm *StorageManager) ResetStorageFolderHealth(index int) error

ResetStorageFolderHealth will reset the read and write statistics for the storage folder.

func (*StorageManager) ResizeStorageFolder

func (sm *StorageManager) ResizeStorageFolder(storageFolderIndex int, newSize uint64) error

ResizeStorageFolder changes the amount of disk space that is going to be allocated to a storage folder.

func (*StorageManager) StorageFolders

func (sm *StorageManager) StorageFolders() (sfms []modules.StorageFolderMetadata)

StorageFolders provides information about all of the storage folders in the host.

Jump to

Keyboard shortcuts

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