client

package
v0.0.1-beta.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 31 Imported by: 7

Documentation

Index

Constants

View Source
const AuthKey = ctxKey("ffstoken")

AuthKey is the key that should be used to set the auth token in a Context.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asks

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

Asks provides an API for viewing asks data.

func (*Asks) Get

func (a *Asks) Get(ctx context.Context) (*ask.Index, error)

Get returns the current index of available asks.

func (*Asks) Query

func (a *Asks) Query(ctx context.Context, query ask.Query) ([]ask.StorageAsk, error)

Query executes a query to retrieve active Asks.

type Client

type Client struct {
	Asks       *Asks
	Miners     *Miners
	Faults     *Faults
	Deals      *Deals
	Wallet     *Wallet
	Reputation *Reputation
	FFS        *FFS
	Health     *Health
	Net        *Net
	// contains filtered or unexported fields
}

Client provides the client api.

func NewClient

func NewClient(ma multiaddr.Multiaddr, opts ...grpc.DialOption) (*Client, error)

NewClient creates a client.

func (*Client) Close

func (c *Client) Close() error

Close closes the client's grpc connection and cancels any active requests.

type Deals

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

Deals provides an API for managing deals and storing data.

func (*Deals) AllDealRecords

func (d *Deals) AllDealRecords(ctx context.Context) ([]deals.DealRecord, error)

AllDealRecords returns a list of all finalized and pending deals. Records are sorted ascending by activation epoch, if available, then timestamp.

func (*Deals) FinalDealRecords

func (d *Deals) FinalDealRecords(ctx context.Context) ([]deals.DealRecord, error)

FinalDealRecords returns a list of all finalized storage deals. Records are sorted ascending by activation epoch then timestamp.

func (*Deals) PendingDealRecords

func (d *Deals) PendingDealRecords(ctx context.Context) ([]deals.DealRecord, error)

PendingDealRecords returns a list of all pending storage deals. Records are sorted ascending by timestamp.

func (*Deals) RetrievalRecords

func (d *Deals) RetrievalRecords(ctx context.Context) ([]deals.RetrievalRecord, error)

RetrievalRecords returns a list of all retrievals. Records are sorted ascending by timestamp.

func (*Deals) Retrieve

func (d *Deals) Retrieve(ctx context.Context, waddr string, cid cid.Cid) (io.Reader, error)

Retrieve is used to fetch data from filecoin.

func (*Deals) Store

func (d *Deals) Store(ctx context.Context, addr string, data io.Reader, dealConfigs []deals.StorageDealConfig, minDuration uint64) ([]cid.Cid, []deals.StorageDealConfig, error)

Store creates a proposal deal for data using wallet addr to all miners indicated by dealConfigs for duration epochs.

func (*Deals) Watch

func (d *Deals) Watch(ctx context.Context, proposals []cid.Cid) (<-chan WatchEvent, error)

Watch returns a channel with state changes of indicated proposals.

type FFS

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

FFS provides the API to create and interact with an FFS instance.

func (*FFS) AddToHot

func (f *FFS) AddToHot(ctx context.Context, data io.Reader) (*cid.Cid, error)

AddToHot allows you to add data to the Hot layer in preparation for pushing a cid config.

func (*FFS) Addrs

func (f *FFS) Addrs(ctx context.Context) ([]api.AddrInfo, error)

Addrs returns a list of addresses managed by the FFS instance.

func (*FFS) CancelJob

func (f *FFS) CancelJob(ctx context.Context, jid ffs.JobID) error

CancelJob signals that the executing Job with JobID jid should be canceled.

func (*FFS) Close

func (f *FFS) Close(ctx context.Context) error

Close terminates the running FFS instance.

func (*FFS) Create

func (f *FFS) Create(ctx context.Context) (string, string, error)

Create creates a new FFS instance, returning the instance ID and auth token.

func (*FFS) CreatePayChannel

func (f *FFS) CreatePayChannel(ctx context.Context, from string, to string, amount uint64) (ffs.PaychInfo, cid.Cid, error)

CreatePayChannel creates a new payment channel.

func (*FFS) DefaultConfig

func (f *FFS) DefaultConfig(ctx context.Context) (ffs.DefaultConfig, error)

DefaultConfig returns the default storage config.

func (*FFS) Get

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

Get returns an io.Reader for reading a stored Cid from the Hot Storage.

func (*FFS) GetCidConfig

func (f *FFS) GetCidConfig(ctx context.Context, c cid.Cid) (*rpc.GetCidConfigResponse, error)

GetCidConfig gets the current config for a cid.

func (*FFS) GetDefaultCidConfig

func (f *FFS) GetDefaultCidConfig(ctx context.Context, c cid.Cid) (ffs.CidConfig, error)

GetDefaultCidConfig returns a CidConfig built from the default storage config and prepped for the provided cid.

func (*FFS) ID

func (f *FFS) ID(ctx context.Context) (ffs.APIID, error)

ID returns the FFS instance ID.

func (*FFS) Info

func (f *FFS) Info(ctx context.Context) (api.InstanceInfo, error)

Info returns information about the FFS instance.

func (*FFS) ListAPI

func (f *FFS) ListAPI(ctx context.Context) ([]ffs.APIID, error)

ListAPI returns a list of existing API instances.

func (*FFS) ListPayChannels

func (f *FFS) ListPayChannels(ctx context.Context) ([]ffs.PaychInfo, error)

ListPayChannels returns a list of payment channels.

func (*FFS) NewAddr

func (f *FFS) NewAddr(ctx context.Context, name string, options ...NewAddressOption) (string, error)

NewAddr created a new wallet address managed by the FFS instance.

func (*FFS) PushConfig

func (f *FFS) PushConfig(ctx context.Context, c cid.Cid, opts ...PushConfigOption) (ffs.JobID, error)

PushConfig push a new configuration for the Cid in the Hot and Cold layers.

func (*FFS) RedeemPayChannel

func (f *FFS) RedeemPayChannel(ctx context.Context, addr string) error

RedeemPayChannel redeems a payment channel.

func (*FFS) Remove

func (f *FFS) Remove(ctx context.Context, 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 (*FFS) Replace

func (f *FFS) Replace(ctx context.Context, c1 cid.Cid, c2 cid.Cid) (ffs.JobID, error)

Replace pushes a CidConfig of c2 equal to c1, and removes c1. This operation is more efficient than manually removing and adding in two separate operations.

func (*FFS) SendFil

func (f *FFS) SendFil(ctx context.Context, from string, to string, amount int64) error

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

func (*FFS) SetDefaultConfig

func (f *FFS) SetDefaultConfig(ctx context.Context, config ffs.DefaultConfig) error

SetDefaultConfig sets the default storage config.

func (*FFS) Show

func (f *FFS) Show(ctx context.Context, c cid.Cid) (*rpc.ShowResponse, error)

Show returns information about the current storage state of a cid.

func (*FFS) WatchJobs

func (f *FFS) WatchJobs(ctx context.Context, ch chan<- JobEvent, jids ...ffs.JobID) error

WatchJobs pushes JobEvents to the provided channel. The provided channel will be owned by the client after the call, so it shouldn't be closed by the client. To stop receiving events, the provided ctx should be canceled. If an error occurs, it will be returned in the Err field of JobEvent and the channel will be closed.

func (*FFS) WatchLogs

func (f *FFS) WatchLogs(ctx context.Context, ch chan<- LogEvent, c cid.Cid, opts ...WatchLogsOption) error

WatchLogs pushes human-friendly messages about Cid executions. The method is blocking and will continue to send messages until the context is canceled. The provided channel is owned by the method and must not be closed.

type Faults

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

Faults provides an API for viewing faults data.

func (*Faults) Get

func (s *Faults) Get(ctx context.Context) (*faults.IndexSnapshot, error)

Get returns the current index of miner faults data.

type Health

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

Health provides an API for checking node Health.

func (*Health) Check

func (health *Health) Check(ctx context.Context) (h.Status, []string, error)

Check returns the node health status and any related messages.

type JobEvent

type JobEvent struct {
	Job ffs.Job
	Err error
}

JobEvent represents an event for Watching a job.

type LogEvent

type LogEvent struct {
	LogEntry ffs.LogEntry
	Err      error
}

LogEvent represents an event for watching cid logs.

type Miners

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

Miners provides an API for viewing miner data.

func (*Miners) Get

func (a *Miners) Get(ctx context.Context) (*miner.IndexSnapshot, error)

Get returns the current index of available asks.

type Net

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

Net provides the Net API.

func (*Net) ConnectPeer

func (net *Net) ConnectPeer(ctx context.Context, addrInfo peer.AddrInfo) error

ConnectPeer connects to a peer.

func (*Net) Connectedness

func (net *Net) Connectedness(ctx context.Context, peerID peer.ID) (n.Connectedness, error)

Connectedness returns the connection status to a peer.

func (*Net) DisconnectPeer

func (net *Net) DisconnectPeer(ctx context.Context, peerID peer.ID) error

DisconnectPeer disconnects from a peer.

func (*Net) FindPeer

func (net *Net) FindPeer(ctx context.Context, peerID peer.ID) (n.PeerInfo, error)

FindPeer finds a peer by peer id.

func (*Net) ListenAddr

func (net *Net) ListenAddr(ctx context.Context) (peer.AddrInfo, error)

ListenAddr returns listener address info for the local node.

func (*Net) Peers

func (net *Net) Peers(ctx context.Context) ([]n.PeerInfo, error)

Peers returns a list of peers.

type NewAddressOption

type NewAddressOption func(r *rpc.NewAddrRequest)

NewAddressOption is a function that changes a NewAddressConfig.

func WithAddressType

func WithAddressType(addressType string) NewAddressOption

WithAddressType specifies the type of address to create.

func WithMakeDefault

func WithMakeDefault(makeDefault bool) NewAddressOption

WithMakeDefault specifies if the new address should become the default.

type PushConfigOption

type PushConfigOption func(r *rpc.PushConfigRequest)

PushConfigOption mutates a push request.

func WithCidConfig

func WithCidConfig(c ffs.CidConfig) PushConfigOption

WithCidConfig overrides the Api default Cid configuration.

func WithOverride

func WithOverride(override bool) PushConfigOption

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

type Reputation

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

Reputation provides an API for viewing reputation data.

func (*Reputation) AddSource

func (r *Reputation) AddSource(ctx context.Context, id string, maddr ma.Multiaddr) error

AddSource adds a new external Source to be considered for reputation generation.

func (*Reputation) GetTopMiners

func (r *Reputation) GetTopMiners(ctx context.Context, limit int) ([]reputation.MinerScore, error)

GetTopMiners gets the top n miners with best score.

type TokenAuth

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

TokenAuth provides token based auth.

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error)

GetRequestMetadata returns request metadata that includes the auth token.

func (TokenAuth) RequireTransportSecurity

func (t TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity specifies if the connection should be secure.

type Wallet

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

Wallet provides an API for managing filecoin wallets.

func (*Wallet) List

func (w *Wallet) List(ctx context.Context) ([]string, error)

List returns all wallet addresses.

func (*Wallet) NewWallet

func (w *Wallet) NewWallet(ctx context.Context, typ string) (string, error)

NewWallet creates a new filecoin address [bls|secp256k1].

func (*Wallet) WalletBalance

func (w *Wallet) WalletBalance(ctx context.Context, address string) (uint64, error)

WalletBalance gets a filecoin wallet's balance.

type WatchEvent

type WatchEvent struct {
	Deal deals.DealInfo
	Err  error
}

WatchEvent is used to send data or error values for Watch.

type WatchLogsOption

type WatchLogsOption func(r *rpc.WatchLogsRequest)

WatchLogsOption is a function that changes GetLogsConfig.

func WithHistory

func WithHistory(enabled bool) WatchLogsOption

WithHistory indicates that prior history logs should be sent in the channel before getting real time logs.

func WithJidFilter

func WithJidFilter(jid ffs.JobID) WatchLogsOption

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL