-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider.go
70 lines (48 loc) · 2.55 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package storagemarket
import (
"context"
"io"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-fil-markets/shared"
)
// ProviderSubscriber is a callback that is run when events are emitted on a StorageProvider
type ProviderSubscriber func(event ProviderEvent, deal MinerDeal)
// StorageProvider provides an interface to the storage market for a single
// storage miner.
type StorageProvider interface {
// Start initializes deal processing on a StorageProvider and restarts in progress deals.
// It also registers the provider with a StorageMarketNetwork so it can receive incoming
// messages on the storage market's libp2p protocols
Start(ctx context.Context) error
// OnReady registers a listener for when the provider comes on line
OnReady(shared.ReadyFunc)
// Stop terminates processing of deals on a StorageProvider
Stop() error
// SetAsk configures the storage miner's ask with the provided prices (for unverified and verified deals),
// duration, and options. Any previously-existing ask is replaced.
SetAsk(price abi.TokenAmount, verifiedPrice abi.TokenAmount, duration abi.ChainEpoch, options ...StorageAskOption) error
// GetAsk returns the storage miner's ask, or nil if one does not exist.
GetAsk() *SignedStorageAsk
// GetLocalDeal gets a deal by signed proposal cid
GetLocalDeal(cid cid.Cid) (MinerDeal, error)
// LocalDealCount gets the number of local deals
LocalDealCount() (int, error)
// ListLocalDeals lists deals processed by this storage provider
ListLocalDeals() ([]MinerDeal, error)
// ListLocalDealsPage lists deals by creation time descending, starting
// at the deal with the given signed proposal cid, skipping offset deals
// and returning up to limit deals
ListLocalDealsPage(startPropCid *cid.Cid, offset int, limit int) ([]MinerDeal, error)
// AddStorageCollateral adds storage collateral
AddStorageCollateral(ctx context.Context, amount abi.TokenAmount) error
// GetStorageCollateral returns the current collateral balance
GetStorageCollateral(ctx context.Context) (Balance, error)
// ImportDataForDeal manually imports data for an offline storage deal
ImportDataForDeal(ctx context.Context, propCid cid.Cid, data io.Reader) error
// SubscribeToEvents listens for events that happen related to storage deals on a provider
SubscribeToEvents(subscriber ProviderSubscriber) shared.Unsubscribe
RetryDealPublishing(propCid cid.Cid) error
AnnounceDealToIndexer(ctx context.Context, proposalCid cid.Cid) error
AnnounceAllDealsToIndexer(ctx context.Context) error
}