Documentation ¶
Index ¶
- Variables
- type APIID
- type CidConfig
- func (c CidConfig) Validate() error
- func (c CidConfig) WithColdEnabled(enabled bool) CidConfig
- func (c CidConfig) WithColdFilCountryCodes(countryCodes []string) CidConfig
- func (c CidConfig) WithColdFilDealDuration(duration int64) CidConfig
- func (c CidConfig) WithColdFilExcludedMiners(miners []string) CidConfig
- func (c CidConfig) WithColdFilRenew(enabled bool, threshold int) CidConfig
- func (c CidConfig) WithColdFilRepFactor(repFactor int) CidConfig
- func (c CidConfig) WithColdFilTrustedMiners(miners []string) CidConfig
- func (c CidConfig) WithHotAllowUnfreeze(allow bool) CidConfig
- func (c CidConfig) WithHotEnabled(enabled bool) CidConfig
- func (c CidConfig) WithHotIpfsAddTimeout(seconds int) CidConfig
- func (c CidConfig) WithRepairable(enabled bool) CidConfig
- type CidInfo
- type CidLogger
- type CidLoggerCtxKey
- type ColdConfig
- type ColdInfo
- type ColdStorage
- type DealError
- type DefaultConfig
- type FilConfig
- type FilInfo
- type FilRenew
- type FilStorage
- type HotConfig
- type HotInfo
- type HotStorage
- type IpfsConfig
- type IpfsHotInfo
- type Job
- type JobID
- type JobStatus
- type LogEntry
- type MinerProposal
- type MinerSelector
- type MinerSelectorFilter
- type Scheduler
- type WalletManager
Constants ¶
This section is empty.
Variables ¶
var ( // EmptyInstanceID represents an empty/invalid Instance ID. EmptyInstanceID = APIID("") )
var ( // EmptyJobID represents an empty JobID. EmptyJobID = JobID("") )
var ( // 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 // the Hot Storage for that Cid. ErrHotStorageDisabled = errors.New("cid disabled in hot storage") )
var JobStatusStr = map[JobStatus]string{ Queued: "Queued", Executing: "Executing", Failed: "Failed", Canceled: "Canceled", Success: "Success", }
JobStatusStr maps JobStatus to describing string.
Functions ¶
This section is empty.
Types ¶
type APIID ¶
type APIID string
APIID is an identifier for a Api instance.
type CidConfig ¶
type CidConfig struct { // Cid is the Cid of the stored data. Cid cid.Cid // Hot has desired storing configuration in Hot Storage. Hot HotConfig // Cold has desired storing configuration in the Cold Storage. Cold ColdConfig // Repairable indicates if this cid config should be tracked // for auto-repair. Repairable bool }
CidConfig has a Cid desired storing configuration for a Cid in Hot and Cold storage.
func (CidConfig) WithColdEnabled ¶
WithColdEnabled allows to enable/disable Cold storage usage.
func (CidConfig) WithColdFilCountryCodes ¶
WithColdFilCountryCodes defines a list of allowed country codes to select miners for deals.
func (CidConfig) WithColdFilDealDuration ¶
WithColdFilDealDuration defines the duration used for deals for Filecoin storage.
func (CidConfig) WithColdFilExcludedMiners ¶
WithColdFilExcludedMiners defines a list of miner addresses which won't be selected for making deals, no matter if they comply to other filters in the configuration.
func (CidConfig) WithColdFilRenew ¶
WithColdFilRenew specifies if deals should be renewed before they expire with a particular threshold chain epochs.
func (CidConfig) WithColdFilRepFactor ¶
WithColdFilRepFactor defines the replication factor for Filecoin storage.
func (CidConfig) WithColdFilTrustedMiners ¶
WithColdFilTrustedMiners defines a list of trusted miners addresses which will be returned if available. If more miners reusults are needed, other filters will be applied as usual.
func (CidConfig) WithHotAllowUnfreeze ¶
WithHotAllowUnfreeze allows the Scheduler to fetch data from the Cold Storage, if the Enabled flag of the Hot Storage switches from false->true.
func (CidConfig) WithHotEnabled ¶
WithHotEnabled allows to enable/disable Hot storage usage.
func (CidConfig) WithHotIpfsAddTimeout ¶
WithHotIpfsAddTimeout specifies a timeout for fetching data in Ipfs.
func (CidConfig) WithRepairable ¶
WithRepairable allows to enable/disable auto-repair.
type CidLogger ¶
type CidLogger interface { Log(context.Context, cid.Cid, string, ...interface{}) Watch(context.Context, chan<- LogEntry) error Get(context.Context, cid.Cid) ([]LogEntry, error) }
CidLogger saves log information about a Cid executions.
type CidLoggerCtxKey ¶
type CidLoggerCtxKey int
CidLoggerCtxKey is a type to use in ctx values for CidLogger.
const ( // CtxKeyJid is the key to store Jid metadata. CtxKeyJid CidLoggerCtxKey = iota )
type ColdConfig ¶
type ColdConfig struct { // Enabled indicates that data will be saved in Cold storage. // If is switched from false->true, it will consider the other attributes // as the desired state of the data in this Storage. Enabled bool // Filecoin describes the desired Filecoin configuration for a Cid in the // Filecoin network. Filecoin FilConfig }
ColdConfig is the desired state of a Cid in a cold layer.
type ColdInfo ¶
type ColdInfo struct {
Filecoin FilInfo
}
ColdInfo contains information about the current storage state of a Cid in the cold layer.
type ColdStorage ¶
type ColdStorage interface { // Store stores a Cid using the provided configuration and // account address. It returns a slice of deal errors happened // during execution. Store(context.Context, cid.Cid, FilConfig) (FilInfo, []DealError, error) // Retrieve retrieves the data using an account address, // and store it in a CAR store. Retrieve(context.Context, cid.Cid, car.Store, string) (cid.Cid, error) // EnsureRenewals executes renewal logic for a Cid under a particular // configuration. It returns a slice of deal errors happened during execution. EnsureRenewals(context.Context, cid.Cid, FilInfo, FilConfig) (FilInfo, []DealError, error) // IsFIlDealActive returns true if the proposal Cid is active on chain; // returns false otherwise. IsFilDealActive(context.Context, cid.Cid) (bool, error) }
ColdStorage is slow/cheap storage for Cid data. It has native support for Filecoin storage.
type DefaultConfig ¶
type DefaultConfig struct { Hot HotConfig Cold ColdConfig Repairable bool }
DefaultConfig contains a default storage configuration for an Api instance.
func (DefaultConfig) Validate ¶
func (dc DefaultConfig) Validate() error
Validate validates a default Cid configuration.
type FilConfig ¶
type FilConfig struct { // RepFactor indicates the desired amount of active deals // with different miners to store the data. While making deals // the other attributes of FilConfig are considered for miner selection. RepFactor int // DealDuration indicates the duration to be used when making new deals. DealDuration int64 // ExcludedMiners is a set of miner addresses won't be ever be selected // when making new deals, even if they comply to other filters. ExcludedMiners []string // TrustedMiners is a set of miner addresses which will be forcibly used // when making new deals. An empty/nil list disables this feature. TrustedMiners []string // CountryCodes indicates that new deals should select miners on specific // countries. CountryCodes []string // Renew indicates deal-renewal configuration. Renew FilRenew // Addr is the wallet address used to store the data in filecoin Addr string }
FilConfig is the desired state of a Cid in the Filecoin network.
type FilInfo ¶
type FilInfo struct { DataCid cid.Cid Proposals []FilStorage }
FilInfo contains information about the current storage state of a Cid in the Filecoin network.
type FilRenew ¶
type FilRenew struct { // Enabled indicates that deal-renewal is enabled for this Cid. Enabled bool // Threshold indicates how many epochs before expiring should trigger // deal renewal. e.g: 100 epoch before expiring. Threshold int }
FilRenew contains renew configuration for a Cid Cold Storage deals.
type FilStorage ¶
type FilStorage struct { ProposalCid cid.Cid Renewed bool Duration int64 ActivationEpoch int64 Miner string }
FilStorage contains Deal information of a storage in Filecoin.
type HotConfig ¶
type HotConfig struct { // Enable indicates if Cid data is stored. If true, it will consider // further configurations to execute actions. Enabled bool // AllowUnfreeze indicates that if data isn't available in the Hot Storage, // it's allowed to be feeded by Cold Storage if available. AllowUnfreeze bool // Ipfs contains configuration related to storing Cid data in a IPFS node. Ipfs IpfsConfig }
HotConfig is the desired storage of a Cid in a Hot Storage.
type HotInfo ¶
type HotInfo struct { Enabled bool Size int Ipfs IpfsHotInfo }
HotInfo contains information about the current storage state of a Cid in the hot layer.
type HotStorage ¶
type HotStorage interface { // Add adds io.Reader data ephemerally (not pinned). Add(context.Context, io.Reader) (cid.Cid, error) // Remove removes a stored Cid. Remove(context.Context, cid.Cid) error // Get retrieves a stored Cid data. Get(context.Context, cid.Cid) (io.Reader, error) // Store stores a Cid. If the data wasn't previously Added, // depending on the implementation it may use internal mechanisms // for pulling the data, e.g: IPFS network Store(context.Context, cid.Cid) (int, error) // Replace replaces a stored Cid with a new one. It's mostly // thought for mutating data doing this efficiently. Replace(context.Context, cid.Cid, cid.Cid) (int, error) // Put adds a raw block. Put(context.Context, blocks.Block) error // IsStore returns true if the Cid is stored, or false // otherwise. IsStored(context.Context, cid.Cid) (bool, error) }
HotStorage is a fast storage layer for Cid data.
type IpfsConfig ¶
type IpfsConfig struct { // AddTimeout is an upper bound on adding data to IPFS node from // the network before failing. AddTimeout int }
IpfsConfig is the desired storage of a Cid in IPFS.
func (*IpfsConfig) Validate ¶
func (ic *IpfsConfig) Validate() error
Validate validates an IpfsConfig.
type IpfsHotInfo ¶
IpfsHotInfo contains information about the current storage state of a Cid in an IPFS node.
type Job ¶
type Job struct { ID JobID APIID APIID Cid cid.Cid Status JobStatus ErrCause string DealErrors []DealError }
Job is a task executed by the Scheduler.
type JobStatus ¶
type JobStatus int
JobStatus is a type for Job statuses.
const ( // Queued indicates the Job is queued in the Scheduler. Queued JobStatus = iota // Executing indicates that the Job is currently being // executed. Executing // Failed indicates the Job failed, with job.ErrCause with // the error cause. Failed // Canceled indicates the Job was canceled from Queued, // and didn't reach execution. Canceled // Success indicates the Job was successfully executed. Success )
type MinerProposal ¶
MinerProposal contains a miners address and storage ask information to make a, most probably, successful deal.
type MinerSelector ¶
type MinerSelector interface { // GetMiners returns a specified amount of miners that satisfy // provided filters. GetMiners(int, MinerSelectorFilter) ([]MinerProposal, error) }
MinerSelector returns miner addresses and ask storage information using a desired strategy.
type MinerSelectorFilter ¶
type MinerSelectorFilter struct { // ExcludedMiners contains miner addresses that should not be considered in // returned results. An empty list means no exclusions. ExcludedMiners []string // TrustedMiners contains miner addresses that will be prioritized // if are available in the query result. If the number of expected // results exceeeds the number of trusted miners, the remaining amount // of results will be returned still applying the rest of the filters // and the MinerSelector sorting logic. TrustedMiners []string // CountryCodes contains long-ISO country names that should be // considered in selected miners. An empty list means no filtering. CountryCodes []string }
MinerSelectorFilter establishes filters that should be considered when returning miners.
type Scheduler ¶
type Scheduler interface { // PushConfig push a new or modified configuration for a Cid. It returns // the JobID which tracks the current state of execution of that task. PushConfig(APIID, CidConfig) (JobID, error) // PushReplace push a new or modified configuration for a Cid, replacing // an existing one. The replaced Cid will be unstored from the Hot Storage. // Also it will be untracked (refer to Untrack() to understand implications) PushReplace(APIID, CidConfig, cid.Cid) (JobID, error) // GetCidInfo returns the current Cid storing state. This state may be different // from CidConfig which is the *desired* state. GetCidInfo(cid.Cid) (CidInfo, error) // GetCidFromHot returns an Reader with the Cid data. If the data isn't in the Hot // Storage, it errors with ErrHotStorageDisabled. GetCidFromHot(context.Context, cid.Cid) (io.Reader, error) // GetJob gets the a Job. GetJob(JobID) (Job, error) // WatchJobs is a blocking method that sends to a channel state updates // for all Jobs created by an Instance. The ctx should be canceled when // to stop receiving updates. WatchJobs(context.Context, chan<- Job, APIID) error // WatchLogs writes new log entries from Cid related executions. // This is a blocking operation that should be canceled by canceling the // provided context. WatchLogs(context.Context, chan<- LogEntry) error // GetLogs returns all registered logs for a Cid. GetLogs(context.Context, cid.Cid) ([]LogEntry, error) //Untrack marks a Cid to be untracked for any background processes such as // deal renewal, or repairing. Untrack(cid.Cid) error }
Scheduler enforces a CidConfig orchestrating Hot and Cold storages.
type WalletManager ¶
type WalletManager interface { // NewAddress creates a new address. NewAddress(context.Context, string) (string, error) // Balance returns the current balance for an address. Balance(context.Context, string) (uint64, error) // SendFil sends fil from one address to another SendFil(ctx context.Context, from string, to string, amount *big.Int) error }
WalletManager provides access to a Lotus wallet for a Lotus node.