powergate: github.com/textileio/powergate/ffs/api Index | Files

package api

import "github.com/textileio/powergate/ffs/api"

Index

Package Files

api.go api_actions.go api_deals.go api_jobs.go api_logs.go api_retrieval.go api_storageinfo.go api_wallet.go istore.go option.go types.go

Variables

var (
    // ErrMustOverrideConfig returned when trying to push config for storing a Cid
    // without the override flag.
    ErrMustOverrideConfig = errors.New("cid already pinned, consider using override flag")
    // ErrReplacedCidNotFound returns when replacing a Cid that isn't stored.
    ErrReplacedCidNotFound = errors.New("provided replaced cid wasn't found")
    // ErrActiveInStorage returns when a Cid is trying to be removed but still defined as active
    // on Hot or Cold storage.
    ErrActiveInStorage = errors.New("can't remove Cid, disable from Hot and Cold storage")
    // ErrHotStorageDisabled returned when trying to fetch a Cid when disabled on Hot Storage.
    // To retrieve the data, is necessary to call unfreeze by enabling the Enabled flag in
    // hot storage for that Cid.
    ErrHotStorageDisabled = errors.New("cid disabled in hot storage")
)
var (
    // ErrNotFound returned when instance configuration doesn't exist.
    ErrNotFound = errors.New("stored item not found")
)

type API Uses

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

API is an Api instance, which owns a Lotus Address and allows to Store and Retrieve Cids from hot and cold storage.

func Load Uses

func Load(ds datastore.Datastore, iid ffs.APIID, sched *scheduler.Scheduler, wm ffs.WalletManager, drm ffs.DealRecordsManager) (*API, error)

Load loads a saved Api instance from its ConfigStore.

func New Uses

func New(ds datastore.Datastore, iid ffs.APIID, sch *scheduler.Scheduler, wm ffs.WalletManager, drm ffs.DealRecordsManager, dc ffs.StorageConfig, addrInfo AddrInfo) (*API, error)

New returns a new Api instance.

func (*API) Addrs Uses

func (i *API) Addrs() []AddrInfo

Addrs returns the wallet addresses.

func (*API) CancelJob Uses

func (i *API) CancelJob(jid ffs.JobID) error

CancelJob cancels an executing Job. If no Job is executing with that JobID, it won't fail.

func (*API) Close Uses

func (i *API) Close() error

Close terminates the running Api.

func (*API) DefaultStorageConfig Uses

func (i *API) DefaultStorageConfig() ffs.StorageConfig

DefaultStorageConfig returns the default StorageConfig.

func (*API) Get Uses

func (i *API) Get(ctx context.Context, c cid.Cid) (io.Reader, error)

Get returns an io.Reader for reading a stored Cid from hot storage.

func (*API) GetRetrieval Uses

func (i *API) GetRetrieval(prID ffs.RetrievalID) (Retrieval, error)

GetRetrieval returns information from a Retrieval using its ID.

func (*API) GetStorageConfigs Uses

func (i *API) GetStorageConfigs(cids ...cid.Cid) (map[cid.Cid]ffs.StorageConfig, error)

GetStorageConfigs returns the current StorageConfigs for a FFS instance, filtered by cids, if provided.

func (*API) GetStorageJob Uses

func (i *API) GetStorageJob(jid ffs.JobID) (ffs.StorageJob, error)

GetStorageJob returns the current state of the specified job.

func (*API) ID Uses

func (i *API) ID() ffs.APIID

ID returns the ID.

func (*API) ListStorageInfo Uses

func (i *API) ListStorageInfo(cids ...cid.Cid) ([]ffs.StorageInfo, error)

ListStorageInfo returns a list of information about all stored cids, filtered by cids if provided.

func (*API) ListStorageJobs Uses

func (i *API) ListStorageJobs(config ListStorageJobsConfig) ([]ffs.StorageJob, bool, string, error)

ListStorageJobs lists StorageJobs according to the provided ListStorageJobsConfig.

func (*API) NewAddr Uses

func (i *API) NewAddr(ctx context.Context, name string, options ...NewAddressOption) (string, error)

NewAddr creates a new address managed by the FFS instance.

func (*API) PushStorageConfig Uses

func (i *API) PushStorageConfig(c cid.Cid, opts ...PushStorageConfigOption) (ffs.JobID, error)

PushStorageConfig push a new configuration for the Cid in the hot and cold storage. If WithOverride opt isn't set it errors with ErrMustOverrideConfig.

func (*API) Remove Uses

func (i *API) Remove(c cid.Cid) error

Remove removes a Cid from being tracked as an active storage. The Cid should have both Hot and Cold storage disabled, if that isn't the case it will return ErrActiveInStorage.

func (*API) RemoveRetrieval Uses

func (i *API) RemoveRetrieval(partialCid cid.Cid) error

RemoveRetrieval removes information and data from a executed retrieval.

func (*API) Replace Uses

func (i *API) Replace(c1 cid.Cid, c2 cid.Cid) (ffs.JobID, error)

Replace pushes a StorageConfig for c2 equal to that of c1, and removes c1. This operation is more efficient than manually removing and adding in two separate operations. c1 and c2 must not be equal.

func (*API) RetrievalDealRecords Uses

func (i *API) RetrievalDealRecords(opts ...deals.DealRecordsOption) ([]deals.RetrievalDealRecord, error)

RetrievalDealRecords returns a list of retrieval deals for this FFS instance according to the provided options.

func (*API) SendFil Uses

func (i *API) SendFil(ctx context.Context, from string, to string, amount *big.Int) error

SendFil sends fil from a managed address to any another address, returns immediately but funds are sent asynchronously.

func (*API) SetDefaultStorageConfig Uses

func (i *API) SetDefaultStorageConfig(c ffs.StorageConfig) error

SetDefaultStorageConfig sets a new default StorageConfig.

func (*API) SignMessage Uses

func (i *API) SignMessage(ctx context.Context, addr string, message []byte) ([]byte, error)

SignMessage signs a message using a managed address.

func (*API) StartRetrieval Uses

func (i *API) StartRetrieval(payloadCid, pieceCid cid.Cid, selector string, miners []string, opts ...RetrievalOption) (Retrieval, error)

StartRetrieval schedules a new job to do a data retrieval.

func (*API) StorageConfigForJob Uses

func (i *API) StorageConfigForJob(jid ffs.JobID) (ffs.StorageConfig, error)

StorageConfigForJob returns the StorageConfig associated with the specified job.

func (*API) StorageDealRecords Uses

func (i *API) StorageDealRecords(opts ...deals.DealRecordsOption) ([]deals.StorageDealRecord, error)

StorageDealRecords lists storage deals for this FFS instance according to the provided options.

func (*API) StorageInfo Uses

func (i *API) StorageInfo(cid cid.Cid) (ffs.StorageInfo, error)

StorageInfo returns the information about a stored Cid. If no information is available, since the Cid was never stored, it returns ErrNotFound.

func (*API) VerifyMessage Uses

func (i *API) VerifyMessage(ctx context.Context, addr string, message, signature []byte) (bool, error)

VerifyMessage verifies a message signature of a message from a managed address.

func (*API) WatchJobs Uses

func (i *API) WatchJobs(ctx context.Context, c chan<- ffs.StorageJob, jids ...ffs.JobID) error

WatchJobs subscribes to Job status changes. If jids is empty, it subscribes to all Job status changes corresonding to the instance. If jids is not empty, it immediately sends current state of those Jobs. If empty, it doesn't.

func (*API) WatchLogs Uses

func (i *API) WatchLogs(ctx context.Context, ch chan<- ffs.LogEntry, c cid.Cid, opts ...GetLogsOption) error

WatchLogs pushes human-friendly messages about Cid executions. The method is blocking and will continue to send messages until the context is canceled.

type AddrInfo Uses

type AddrInfo struct {
    Name string
    Addr string
    Type string
}

AddrInfo provides information about a wallet address.

type GetLogsConfig Uses

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

GetLogsConfig contains configuration for a stream-log of human-friendly messages for a Cid execution.

type GetLogsOption Uses

type GetLogsOption func(config *GetLogsConfig)

GetLogsOption is a function that changes GetLogsConfig.

func WithHistory Uses

func WithHistory(enabled bool) GetLogsOption

WithHistory indicates that prior log history should be sent to the channel before getting realtime logs.

func WithJidFilter Uses

func WithJidFilter(jid ffs.JobID) GetLogsOption

WithJidFilter filters only log messages of a Cid related to the Job with id jid.

type InstanceConfig Uses

type InstanceConfig struct {
    ID                   ffs.APIID
    Addrs                map[string]AddrInfo
    DefaultStorageConfig ffs.StorageConfig
}

InstanceConfig has general information about a Api instance.

type ListStorageJobsConfig Uses

type ListStorageJobsConfig struct {
    // CidFilter filters StorageJobs list to the specified cid. Defaults to no filter.
    CidFilter cid.Cid
    // Limit limits the number of StorageJobs returned. Defaults to no limit.
    Limit uint64
    // Ascending returns the StorageJobs ascending by time. Defaults to false, descending.
    Ascending bool
    // Select specifies to return StorageJobs in the specified state.
    Select ListStorageJobsSelect
    // NextPageToken sets the slug from which to start building the next page of results.
    NextPageToken string
}

ListStorageJobsConfig controls the behavior for listing StorageJobs.

type ListStorageJobsSelect Uses

type ListStorageJobsSelect int

ListStorageJobsSelect specifies which StorageJobs to list.

const (
    // All lists all StorageJobs and is the default.
    All ListStorageJobsSelect = iota
    // Queued lists queued StorageJobs.
    Queued
    // Executing lists executing StorageJobs.
    Executing
    // Final lists final StorageJobs.
    Final
)

type NewAddressConfig Uses

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

NewAddressConfig contains options for creating a new wallet address.

type NewAddressOption Uses

type NewAddressOption func(config *NewAddressConfig)

NewAddressOption is a function that changes a NewAddressConfig.

func WithAddressType Uses

func WithAddressType(addressType string) NewAddressOption

WithAddressType specifies the type of address to create.

func WithMakeDefault Uses

func WithMakeDefault(makeDefault bool) NewAddressOption

WithMakeDefault specifies if the new address should become the default.

type PushStorageConfigOption Uses

type PushStorageConfigOption func(o *pushStorageConfigConfig) error

PushStorageConfigOption mutates a push configuration.

func WithDealImport Uses

func WithDealImport(dealIDs []uint64) PushStorageConfigOption

WithDealImport provides active deals to create/augment the storage info of the cid.

func WithNoExec Uses

func WithNoExec(noExec bool) PushStorageConfigOption

WithNoExec avoids creating a Job for the new configuration.

func WithOverride Uses

func WithOverride(override bool) PushStorageConfigOption

WithOverride allows a new push configuration to override an existing one. It's used as an extra security measure to avoid unwanted configuration changes.

func WithStorageConfig Uses

func WithStorageConfig(c ffs.StorageConfig) PushStorageConfigOption

WithStorageConfig overrides the Api default Cid configuration.

type Retrieval Uses

type Retrieval struct {
    ID            ffs.RetrievalID
    PayloadCid    cid.Cid
    PieceCid      cid.Cid
    Selector      string
    Miners        []string
    WalletAddress string
    MaxPrice      uint64
    JID           ffs.JobID
    CreatedAt     time.Time

    // Possibly empty
    RetrievalMiner string
    DataCid        cid.Cid
    Size           uint64
}

Retrieval indicates information of a retrieval in the Filecoin network.

type RetrievalOption Uses

type RetrievalOption func(*retrievalConfig)

RetrievalOption provides a retrieval configuration setup.

func WithRetrievalMaxPrice Uses

func WithRetrievalMaxPrice(maxPrice uint64) RetrievalOption

WithRetrievalMaxPrice indicates which is the maximum prices to pay for the retrieval.

func WithRetrievalWalletAddress Uses

func WithRetrievalWalletAddress(addr string) RetrievalOption

WithRetrievalWalletAddress indicates which wallet address to use for doing the deal retrieval.

Package api imports 17 packages (graph) and is imported by 8 packages. Updated 2021-01-28. Refresh now. Tools for package owners.