Documentation ¶
Index ¶
- Variables
- type APIID
- type APIIDPinnedCid
- type AuthEntry
- type ColdConfig
- type ColdInfo
- type ColdStorage
- type DealError
- type DealRecordsManager
- type FetchInfo
- type FilConfig
- type FilInfo
- type FilRenew
- type FilStorage
- type HotConfig
- type HotInfo
- type HotStorage
- type IpfsConfig
- type IpfsHotInfo
- type JobID
- type JobLogger
- type JobLoggerCtxKey
- type JobStatus
- type LogEntry
- type MinerProposal
- type MinerSelector
- type MinerSelectorFilter
- type PaychDir
- type PaychInfo
- type PinnedCid
- type RetrievalID
- type RetrievalInfo
- type RetrievalJob
- type StorageConfig
- func (s StorageConfig) Validate() error
- func (s StorageConfig) WithColdAddr(addr string) StorageConfig
- func (s StorageConfig) WithColdEnabled(enabled bool) StorageConfig
- func (s StorageConfig) WithColdFastRetrieval(enabled bool) StorageConfig
- func (s StorageConfig) WithColdFilCountryCodes(countryCodes []string) StorageConfig
- func (s StorageConfig) WithColdFilDealDuration(duration int64) StorageConfig
- func (s StorageConfig) WithColdFilExcludedMiners(miners []string) StorageConfig
- func (s StorageConfig) WithColdFilRenew(enabled bool, threshold int) StorageConfig
- func (s StorageConfig) WithColdFilRepFactor(repFactor int) StorageConfig
- func (s StorageConfig) WithColdFilTrustedMiners(miners []string) StorageConfig
- func (s StorageConfig) WithColdMaxPrice(maxPrice uint64) StorageConfig
- func (s StorageConfig) WithColdStartDealOffset(offset int64) StorageConfig
- func (s StorageConfig) WithFastRetrieval(enabled bool) StorageConfig
- func (s StorageConfig) WithHotAllowUnfreeze(allow bool) StorageConfig
- func (s StorageConfig) WithHotEnabled(enabled bool) StorageConfig
- func (s StorageConfig) WithHotIpfsAddTimeout(seconds int) StorageConfig
- func (s StorageConfig) WithRepairable(enabled bool) StorageConfig
- func (s StorageConfig) WithUnfreezeMaxPrice(maxPrice uint64) StorageConfig
- type StorageInfo
- type StorageJob
- 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 ( // EmptyRetrievalID is an undef retrieval id. EmptyRetrievalID = RetrievalID("") )
var JobStatusStr = map[JobStatus]string{ Unspecified: "Unspecified", Queued: "Queued", Executing: "Executing", Failed: "Failed", Canceled: "Canceled", Success: "Success", }
JobStatusStr maps JobStatus to describing string.
var PaychDirStr = map[PaychDir]string{ PaychDirUnspecified: "Unspecified", PaychDirInbound: "Inbound", PaychDirOutbound: "Outbound", }
PaychDirStr maps PaychDirs to describing string.
Functions ¶
This section is empty.
Types ¶
type APIID ¶
type APIID string
APIID is an identifier for a Api instance.
type APIIDPinnedCid ¶ added in v1.2.2
APIIDPinnedCid has information about a Cid pinned by a user.
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 cold storage.
type ColdInfo ¶
ColdInfo contains information about the current storage state of a Cid in cold storage.
type ColdStorage ¶
type ColdStorage interface { // Store stores a Cid using the provided configuration and // account address. It returns a slice of accepted proposed deals, // a slice of rejected proposal deals, and the size of the data. Store(context.Context, cid.Cid, FilConfig) ([]cid.Cid, []DealError, abi.PaddedPieceSize, error) // WaitForDeal blocks the provided Deal Proposal reach a // final state. If the deal finishes successfully it returns a FilStorage // result. If the deal finished with error, it returns a ffs.DealError // error result, so it should be considered in error handling. WaitForDeal(context.Context, cid.Cid, cid.Cid, time.Duration, chan deals.StorageDealInfo) (FilStorage, error) // Fetch fetches the cid data in the underlying storage. Fetch(context.Context, cid.Cid, *cid.Cid, string, []string, uint64, string) (FetchInfo, 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, time.Duration, chan deals.StorageDealInfo) (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 DealRecordsManager ¶
type DealRecordsManager interface { ListStorageDealRecords(opts ...deals.DealRecordsOption) ([]deals.StorageDealRecord, error) ListRetrievalDealRecords(opts ...deals.DealRecordsOption) ([]deals.RetrievalDealRecord, error) }
DealRecordsManager provides access to deal records.
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 // DealMinDuration indicates the duration to be used when making new deals. DealMinDuration 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 // MaxPrice is the maximum price that will be spent per RepFactor to store the data in units of attoFIL per GiB per epoch MaxPrice uint64 // FastRetrieval indicates that created deals should enable the // fast retrieval feature. FastRetrieval bool // DealStartOffset indicates how many epochs in the future impose a // deadline to new deals being active on-chain. This value might influence // if miners accept deals, since they should seal fast enough to satisfy // this constraint. DealStartOffset int64 }
FilConfig is the desired state of a Cid in the Filecoin network.
type FilInfo ¶
type FilInfo struct { // DataCid corresponds to the PayloadCid of the deal. DataCid cid.Cid // Size is the size of the Piece. Recall that this size // is which is accounted for payment. Also is equal or // greater than the original data size. // This value might be zero for imported deals; if that's // the case, will be re-calculated in the next made deal. Size uint64 // Proposals contains known deals for the data. 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 of the deal. ProposalCid cid.Cid // PieceCid is the piece Cid. PieceCid cid.Cid // Renewed indicates if this deal was // already renewed, so it can expiry // safely if renewals are enabled. Renewed bool // Duration is the duration of the deal. Duration int64 // ActivationEpoch is the epoch in which // the deal was activated. ActivationEpoch int64 // StartEpoch is the starting epoch in which // the deal is considered active on-chain. StartEpoch uint64 // Miner is the miner address which is storing // deals data. Miner string // EpochPrice is the price of attoFil per GiB // per epoch paid in this deal. EpochPrice uint64 }
FilStorage contains Deal information of a storage in Filecoin. This information is used in FFS may be used by FFS logic to provide repair, renwal, or retrieval tasks.
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 hot storage, // it's allowed to be feeded by Cold Storage if available. AllowUnfreeze bool // UnfreezeMaxPrice indicates the maximum amount of attoFil to pay for // retrieval of data to unfreeze. UnfreezeMaxPrice uint64 // 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 hot storage.
type HotStorage ¶
type HotStorage interface { // Stage adds io.Reader and stage-pins it. Stage(context.Context, APIID, io.Reader) (cid.Cid, error) // StageCid stage-pins a cid. StageCid(context.Context, APIID, cid.Cid) error // Unpin unpins a Cid. Unpin(context.Context, APIID, cid.Cid) error // Get retrieves a stored Cid data. Get(context.Context, cid.Cid) (io.Reader, error) // Pin pins 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 Pin(context.Context, APIID, 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, APIID, cid.Cid, cid.Cid) (int, error) // IsPinned returns true if the Cid is pinned, or false // otherwise. IsPinned(context.Context, APIID, cid.Cid) (bool, error) // GCStaged unpins Cids that are stage-pinned that aren't // contained in a exclude list, and were pinned before a time. GCStaged(context.Context, []cid.Cid, time.Time) ([]cid.Cid, error) // PinnedCids returns pinned cids information. PinnedCids(context.Context) ([]PinnedCid, 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 JobLogger ¶ added in v0.6.0
type JobLogger interface { Log(context.Context, string, ...interface{}) Watch(context.Context, chan<- LogEntry) error GetByCid(context.Context, APIID, cid.Cid) ([]LogEntry, error) }
JobLogger saves log information about a storage and retrieval tasks.
type JobLoggerCtxKey ¶ added in v0.6.0
type JobLoggerCtxKey int
JobLoggerCtxKey is a type to use in ctx values for CidLogger.
const ( // CtxKeyJid is a context-key to indicate the Job ID for JobLogger. CtxKeyJid JobLoggerCtxKey = iota // CtxStorageCid is the context-key to indicate the Cid of a // StorageJob for JobLogger. CtxStorageCid // CtxRetrievalID is the context-key to indicate the RetrievalID of // a RetrievalJob for JobLogger. CtxRetrievalID // CtxAPIID is the context-key to indicate which APIID owns the log // entry. CtxAPIID )
type JobStatus ¶
type JobStatus int
JobStatus is a type for Job statuses.
const ( // Unspecified indicates a default or empty value. Unspecified JobStatus = iota // Queued indicates the Job is queued in the Scheduler. Queued // 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 // MaxPrice is the max ask price to consider when selecting miner deals MaxPrice uint64 // PieceSize is the piece size of the data. PieceSize uint64 }
MinerSelectorFilter establishes filters that should be considered when returning miners.
type PinnedCid ¶ added in v1.2.2
type PinnedCid struct { Cid cid.Cid APIIDs []APIIDPinnedCid }
PinnedCid provides information about a pinned Cid.
type RetrievalID ¶ added in v0.6.0
type RetrievalID string
RetrievalID is the identifier of a Filecoin retrieval.
func NewRetrievalID ¶ added in v0.6.0
func NewRetrievalID() RetrievalID
NewRetrievalID returns an new retrieval ID.
func (RetrievalID) String ¶ added in v0.6.0
func (ri RetrievalID) String() string
String returns a string representation of RetrievalID.
type RetrievalInfo ¶ added in v0.6.0
type RetrievalInfo struct { ID RetrievalID DataCid cid.Cid TotalPaid uint64 MinerAddr string Size int64 CreatedAt time.Time }
RetrievalInfo has data about an executed Filecoin retrieval.
type RetrievalJob ¶ added in v0.6.0
type RetrievalJob struct { ID JobID APIID APIID RetrievalID RetrievalID Status JobStatus ErrCause string }
RetrievalJob is a retrieval task executed by the Scheduler.
type StorageConfig ¶ added in v0.2.0
type StorageConfig struct { Hot HotConfig Cold ColdConfig Repairable bool }
StorageConfig contains a default storage configuration for an Api instance.
func (StorageConfig) Validate ¶ added in v0.2.0
func (s StorageConfig) Validate() error
Validate validates a StorageConfig.
func (StorageConfig) WithColdAddr ¶ added in v0.2.0
func (s StorageConfig) WithColdAddr(addr string) StorageConfig
WithColdAddr specifies the wallet address that should be used for transactions.
func (StorageConfig) WithColdEnabled ¶ added in v0.2.0
func (s StorageConfig) WithColdEnabled(enabled bool) StorageConfig
WithColdEnabled allows to enable/disable Cold storage usage.
func (StorageConfig) WithColdFastRetrieval ¶ added in v0.6.0
func (s StorageConfig) WithColdFastRetrieval(enabled bool) StorageConfig
WithColdFastRetrieval sets the Fast Retrieval feature for new deals.
func (StorageConfig) WithColdFilCountryCodes ¶ added in v0.2.0
func (s StorageConfig) WithColdFilCountryCodes(countryCodes []string) StorageConfig
WithColdFilCountryCodes defines a list of allowed country codes to select miners for deals.
func (StorageConfig) WithColdFilDealDuration ¶ added in v0.2.0
func (s StorageConfig) WithColdFilDealDuration(duration int64) StorageConfig
WithColdFilDealDuration defines the duration used for deals for Filecoin storage.
func (StorageConfig) WithColdFilExcludedMiners ¶ added in v0.2.0
func (s StorageConfig) WithColdFilExcludedMiners(miners []string) StorageConfig
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 (StorageConfig) WithColdFilRenew ¶ added in v0.2.0
func (s StorageConfig) WithColdFilRenew(enabled bool, threshold int) StorageConfig
WithColdFilRenew specifies if deals should be renewed before they expire with a particular threshold chain epochs.
func (StorageConfig) WithColdFilRepFactor ¶ added in v0.2.0
func (s StorageConfig) WithColdFilRepFactor(repFactor int) StorageConfig
WithColdFilRepFactor defines the replication factor for Filecoin storage.
func (StorageConfig) WithColdFilTrustedMiners ¶ added in v0.2.0
func (s StorageConfig) WithColdFilTrustedMiners(miners []string) StorageConfig
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 (StorageConfig) WithColdMaxPrice ¶ added in v0.2.0
func (s StorageConfig) WithColdMaxPrice(maxPrice uint64) StorageConfig
WithColdMaxPrice specifies the max price that should be considered for deal asks even when all other filers match.
func (StorageConfig) WithColdStartDealOffset ¶ added in v0.6.1
func (s StorageConfig) WithColdStartDealOffset(offset int64) StorageConfig
WithColdStartDealOffset sets the maximum time in epochs a new deal must be active on-chain.
func (StorageConfig) WithFastRetrieval ¶ added in v0.6.0
func (s StorageConfig) WithFastRetrieval(enabled bool) StorageConfig
WithFastRetrieval specifies if deal fast retrieval flag on new deals is enabled.
func (StorageConfig) WithHotAllowUnfreeze ¶ added in v0.2.0
func (s StorageConfig) WithHotAllowUnfreeze(allow bool) StorageConfig
WithHotAllowUnfreeze allows the Scheduler to fetch data from cold storage, if the Enabled flag of hot storage switches from false->true.
func (StorageConfig) WithHotEnabled ¶ added in v0.2.0
func (s StorageConfig) WithHotEnabled(enabled bool) StorageConfig
WithHotEnabled allows to enable/disable Hot storage usage.
func (StorageConfig) WithHotIpfsAddTimeout ¶ added in v0.2.0
func (s StorageConfig) WithHotIpfsAddTimeout(seconds int) StorageConfig
WithHotIpfsAddTimeout specifies a timeout for fetching data in Ipfs.
func (StorageConfig) WithRepairable ¶ added in v0.2.0
func (s StorageConfig) WithRepairable(enabled bool) StorageConfig
WithRepairable allows to enable/disable auto-repair.
func (StorageConfig) WithUnfreezeMaxPrice ¶ added in v0.6.0
func (s StorageConfig) WithUnfreezeMaxPrice(maxPrice uint64) StorageConfig
WithUnfreezeMaxPrice indicates the maximum price to pay for an unfreeze procedure.
type StorageInfo ¶ added in v1.0.0
type StorageInfo struct { // APIID indicate from which instance this // information belongs. APIID APIID // JobID indicates the Job ID which updated // the current information. It *may be empty* if // the data was imported manually. JobID JobID // Cid of payload. Cid cid.Cid // Created is the timestamp of the data. Created time.Time // Hot contains hot storage information. Hot HotInfo // Cold contains cold storage information. Cold ColdInfo }
StorageInfo contains information about the current storage state of a Cid.
type StorageJob ¶ added in v0.6.0
type StorageJob struct { ID JobID APIID APIID Cid cid.Cid Status JobStatus ErrCause string DealInfo []deals.StorageDealInfo DealErrors []DealError CreatedAt int64 }
StorageJob is a task executed by the Scheduler.
type WalletManager ¶
type WalletManager interface { // MasterAddr returns the master address. // Will return address.Undef is Powergate was started with no master address. MasterAddr() address.Address // NewAddress creates a new address. NewAddress(context.Context, string) (string, error) // Balance returns the current balance for an address. Balance(context.Context, string) (*big.Int, error) // SendFil sends fil from one address to another. SendFil(context.Context, string, string, *big.Int) error // Sign signs a message using an address. Sign(context.Context, string, []byte) ([]byte, error) // Verify verifies if a message was signed with an address. Verify(context.Context, string, []byte, []byte) (bool, error) }
WalletManager provides access to a Lotus wallet for a Lotus node.