Documentation ¶
Index ¶
- Variables
- type TokenRecord
- type TokenStorage
- func (t *TokenStorage) AddResources(id types.TokenID, resourceType types.Specifier, amount int64) error
- func (t *TokenStorage) AddSectors(id types.TokenID, sectorsIDs []crypto.Hash, time time.Time) (TokenRecord, error)
- func (t *TokenStorage) AttachSectors(sectorIDs map[types.TokenID][]crypto.Hash, callTime time.Time) error
- func (t *TokenStorage) CheckExpiration(frequency time.Duration, done chan bool)
- func (t *TokenStorage) Close(ctx context.Context) error
- func (t *TokenStorage) EnoughStorageResource(id types.TokenID, sectorsNum int64, now time.Time) (bool, error)
- func (t *TokenStorage) ListSectorIDs(id types.TokenID, pageID string, limit int) (sectorIDs []crypto.Hash, nextPageID string, err error)
- func (t *TokenStorage) RecordDownload(id types.TokenID, downloadBytes, sectorAccesses int64, callTime time.Time) (TokenRecord, error)
- func (t *TokenStorage) ReferencedSectorIDs() ([]crypto.Hash, error)
- func (t *TokenStorage) RemoveSpecificSectors(id types.TokenID, sectorIDs []crypto.Hash, time time.Time) error
- func (t *TokenStorage) TokenRecord(id types.TokenID) (TokenRecord, error)
- type TokenStorageInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInsufficientDownloadBytes is an error indicating lack of DownloadBytes resource on the token. ErrInsufficientDownloadBytes = errors.New("insufficient DownloadBytes for this operation") // ErrInsufficientSectorAccesses is an error indicating lack of SectorAccesses resource on the token. ErrInsufficientSectorAccesses = errors.New("insufficient SectorAccesses for this operation") // ErrInsufficientDownloadBytesAndSectorAccesses is an error indicating lack of DownloadBytes and SectorAccesses resources on the token. ErrInsufficientDownloadBytesAndSectorAccesses = errors.New("insufficient DownloadBytes and SectorAccesses for this operation") // ErrInsufficientUploadBytes is an error indicating lack of UploadBytes resource on the token. ErrInsufficientUploadBytes = errors.New("insufficient UploadBytes for this operation") // ErrInsufficientStorage is an error indicating lack of Storage resource on the token. ErrInsufficientStorage = errors.New("insufficient Storage for this operation") )
Functions ¶
This section is empty.
Types ¶
type TokenRecord ¶
type TokenRecord struct { DownloadBytes int64 UploadBytes int64 SectorAccesses int64 TokenStorageInfo TokenStorageInfo }
TokenRecord include information about token record.
type TokenStorage ¶
type TokenStorage struct {
// contains filtered or unexported fields
}
TokenStorage - storage of tokens for prepaid downloads.
func NewTokenStorage ¶
func NewTokenStorage(stManager modules.StorageManager, dir string) (*TokenStorage, error)
NewTokenStorage - create new storage of tokens for prepaid downloads.
func (*TokenStorage) AddResources ¶
func (t *TokenStorage) AddResources(id types.TokenID, resourceType types.Specifier, amount int64) error
AddResources - add resource to token.
func (*TokenStorage) AddSectors ¶
func (t *TokenStorage) AddSectors(id types.TokenID, sectorsIDs []crypto.Hash, time time.Time) (TokenRecord, error)
AddSectors add sectors to token.
func (*TokenStorage) AttachSectors ¶
func (t *TokenStorage) AttachSectors(sectorIDs map[types.TokenID][]crypto.Hash, callTime time.Time) error
AttachSectors attach sector to contract.
func (*TokenStorage) CheckExpiration ¶
func (t *TokenStorage) CheckExpiration(frequency time.Duration, done chan bool)
CheckExpiration remove sectors from token when token storage resource ends.
func (*TokenStorage) Close ¶
func (t *TokenStorage) Close(ctx context.Context) error
Close - drain event queue and close storage.
func (*TokenStorage) EnoughStorageResource ¶
func (t *TokenStorage) EnoughStorageResource(id types.TokenID, sectorsNum int64, now time.Time) (bool, error)
EnoughStorageResource checks if there is enough storage resource on token to store existing sectors and new ones, return false if not enough.
func (*TokenStorage) ListSectorIDs ¶
func (t *TokenStorage) ListSectorIDs(id types.TokenID, pageID string, limit int) (sectorIDs []crypto.Hash, nextPageID string, err error)
ListSectorIDs returns list of sector ids.
func (*TokenStorage) RecordDownload ¶
func (t *TokenStorage) RecordDownload(id types.TokenID, downloadBytes, sectorAccesses int64, callTime time.Time) (TokenRecord, error)
RecordDownload set token record fields.
func (*TokenStorage) ReferencedSectorIDs ¶ added in v1.8.5
func (t *TokenStorage) ReferencedSectorIDs() ([]crypto.Hash, error)
ReferencedSectorIDs returns a slice of sectorIDs representing a snapshot of sectors referenced by all tokens
func (*TokenStorage) RemoveSpecificSectors ¶
func (t *TokenStorage) RemoveSpecificSectors(id types.TokenID, sectorIDs []crypto.Hash, time time.Time) error
RemoveSpecificSectors removes only passed sectors ids.
func (*TokenStorage) TokenRecord ¶
func (t *TokenStorage) TokenRecord(id types.TokenID) (TokenRecord, error)
TokenRecord return token record by id.