-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathprovider.go
60 lines (43 loc) · 2.25 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
package retrievalmarket
import (
"context"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-fil-markets/shared"
)
// ProviderSubscriber is a callback that is registered to listen for retrieval events on a provider
type ProviderSubscriber func(event ProviderEvent, state ProviderDealState)
// ProviderQueryEventSubscriber is a callback that is registered to listen for query message events
type ProviderQueryEventSubscriber func(evt ProviderQueryEvent)
// ProviderValidationSubscriber is a callback that is registered to listen for validation events
type ProviderValidationSubscriber func(evt ProviderValidationEvent)
// RetrievalProvider is an interface by which a provider configures their
// retrieval operations and monitors deals received and process
type RetrievalProvider interface {
// Start begins listening for deals on the given host
Start(ctx context.Context) error
// OnReady registers a listener for when the provider comes on line
OnReady(shared.ReadyFunc)
// Stop stops handling incoming requests
Stop() error
// SetAsk sets the retrieval payment parameters that this miner will accept
SetAsk(ask *Ask)
// GetAsk returns the retrieval providers # information
GetAsk() *Ask
// GetDynamicAsk quotes a dynamic price for the retrieval deal by calling the user configured
// dynamic # function. It passes the static price parameters set in the Ask Store to the # function.
GetDynamicAsk(ctx context.Context, input #Input, storageDeals []abi.DealID) (Ask, error)
// SubscribeToEvents listens for events that happen related to client retrievals
SubscribeToEvents(subscriber ProviderSubscriber) Unsubscribe
// SubscribeToQueryEvents subscribes to an event that is fired when a message
// is received on the query protocol
SubscribeToQueryEvents(subscriber ProviderQueryEventSubscriber) Unsubscribe
// SubscribeToValidationEvents subscribes to an event that is fired when the
// provider validates a request for data
SubscribeToValidationEvents(subscriber ProviderValidationSubscriber) Unsubscribe
ListDeals() map[ProviderDealIdentifier]ProviderDealState
}
// AskStore is an interface which provides access to a persisted retrieval Ask
type AskStore interface {
GetAsk() *Ask
SetAsk(ask *Ask) error
}