fcrclient

package
v0.0.0-...-f1dce6f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package fcrclient - reference implementation in Go (Golang) language of a Retrieval Client used in FileCoin Secondary Retrieval network. This package contains methods and structures required for the Retrieval Client to operate: find Retrieval Gateways, find Retrieval Offers, set Retrieval Offer prices and etc. The main structure is FilecoinRetrievalClient

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSettings

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

ClientSettings holds the library configuration

func (ClientSettings) BlockchainPrivateKey

func (c ClientSettings) BlockchainPrivateKey() *fcrcrypto.KeyPair

BlockchainPrivateKey returns the BlockchainPrivateKey

func (ClientSettings) ClientID

func (c ClientSettings) ClientID() *nodeid.NodeID

ClientID returns the ClientID

func (ClientSettings) EstablishmentTTL

func (c ClientSettings) EstablishmentTTL() int64

EstablishmentTTL returns the establishmentTTL

func (ClientSettings) LotusAP

func (c ClientSettings) LotusAP() string

LotusAP returns the lotusAP

func (ClientSettings) LotusAuthToken

func (c ClientSettings) LotusAuthToken() string

LotusAuthToken returns the lotus authorization token

func (ClientSettings) OfferPrice

func (c ClientSettings) OfferPrice() *big.Int

OfferPrice returns offer price

func (ClientSettings) RegisterURL

func (c ClientSettings) RegisterURL() string

RegisterURL returns the register URL

func (ClientSettings) RetrievalPrivateKey

func (c ClientSettings) RetrievalPrivateKey() *fcrcrypto.KeyPair

RetrievalPrivateKey returns the RetrievalPrivateKey

func (ClientSettings) RetrievalPrivateKeyVer

func (c ClientSettings) RetrievalPrivateKeyVer() *fcrcrypto.KeyVersion

RetrievalPrivateKeyVer returns the RetrievalPrivateKeyVer

func (ClientSettings) SearchPrice

func (c ClientSettings) SearchPrice() *big.Int

SearchPrice returns the search price

func (ClientSettings) TopUpAmount

func (c ClientSettings) TopUpAmount() *big.Int

TopUpAmount returns the top up amount

func (ClientSettings) WalletPrivateKey

func (c ClientSettings) WalletPrivateKey() string

WalletPrivateKey returns the wallet private key

type FilecoinRetrievalClient

type FilecoinRetrievalClient struct {
	Settings ClientSettings

	// List of gateways this client can potentially use
	GatewaysToUse     map[string]register.GatewayRegistrar
	GatewaysToUseLock sync.RWMutex

	// List of gateway in use. A client may request a node be added to this list
	ActiveGateways     map[string]register.GatewayRegistrar
	ActiveGatewaysLock sync.RWMutex
	// contains filtered or unexported fields
}

FilecoinRetrievalClient is an example implementation using the api, which holds information about the interaction of the Filecoin Retrieval Client with Filecoin Retrieval Gateways.

func NewFilecoinRetrievalClient

func NewFilecoinRetrievalClient(settings ClientSettings, registerMgr *fcrregistermgr.FCRRegisterMgr) (*FilecoinRetrievalClient, error)

NewFilecoinRetrievalClient initialise the Filecoin Retrieval Client library

func (*FilecoinRetrievalClient) AddActiveGateways

func (c *FilecoinRetrievalClient) AddActiveGateways(gwNodeIDs []*nodeid.NodeID) int

AddActiveGateways adds one or more gateways to active gateway map. Returns the number of gateways added.

func (*FilecoinRetrievalClient) AddGatewaysToUse

func (c *FilecoinRetrievalClient) AddGatewaysToUse(gwNodeIDs []*nodeid.NodeID) int

AddGatewaysToUse adds one or more gateways to use.

func (*FilecoinRetrievalClient) FindDHTOfferAck

func (c *FilecoinRetrievalClient) FindDHTOfferAck(contentID *cid.ContentID, gatewayID *nodeid.NodeID, providerID *nodeid.NodeID) (bool, error)

FindDHTOfferAck finds offer ack for a cid, gateway pair

func (*FilecoinRetrievalClient) FindGateways

func (c *FilecoinRetrievalClient) FindGateways(location string, maxNumToLocate int) ([]*nodeid.NodeID, error)

FindGateways find gateways located near to the specified location. Use AddGateways to use these gateways.

func (*FilecoinRetrievalClient) FindOffersDHTDiscovery

func (c *FilecoinRetrievalClient) FindOffersDHTDiscovery(contentID *cid.ContentID, gatewayID *nodeid.NodeID, numDHT int64) (map[string]*[]cidoffer.SubCIDOffer, error)

FindOffersDHTDiscovery finds offer using dht discovery from given gateways

func (*FilecoinRetrievalClient) FindOffersDHTDiscoveryV2

func (c *FilecoinRetrievalClient) FindOffersDHTDiscoveryV2(contentID *cid.ContentID, gatewayID *nodeid.NodeID, numDHT int64, offersNumberLimit int) (map[string]*[]cidoffer.SubCIDOffer, error)

FindOffersDHTDiscoveryV2 finds offer using dht discovery from given gateway with maximum number of offers offersNumberLimit - maximum number of offers the client asking to have

func (*FilecoinRetrievalClient) FindOffersStandardDiscovery

func (c *FilecoinRetrievalClient) FindOffersStandardDiscovery(contentID *cid.ContentID, gatewayID *nodeid.NodeID) ([]cidoffer.SubCIDOffer, error)

FindOffersStandardDiscovery finds offer using standard discovery from given gateways

func (*FilecoinRetrievalClient) FindOffersStandardDiscoveryV2

func (c *FilecoinRetrievalClient) FindOffersStandardDiscoveryV2(contentID *cid.ContentID, gatewayID *nodeid.NodeID, maxOffers int) ([]cidoffer.SubCIDOffer, error)

FindOffersStandardDiscoveryV2 finds offer using standard discovery from given gateways

func (*FilecoinRetrievalClient) GetActiveGateways

func (c *FilecoinRetrievalClient) GetActiveGateways() []*nodeid.NodeID

GetActiveGateways returns the list of gateways that are active.

func (*FilecoinRetrievalClient) GetGatewaysToUse

func (c *FilecoinRetrievalClient) GetGatewaysToUse() []*nodeid.NodeID

GetGatewaysToUse returns the list of gateways to use.

func (*FilecoinRetrievalClient) PaymentMgr

func (*FilecoinRetrievalClient) RemoveActiveGateways

func (c *FilecoinRetrievalClient) RemoveActiveGateways(gwNodeIDs []*nodeid.NodeID) int

RemoveActiveGateways removes one or more gateways from the list of Gateways in active.

func (*FilecoinRetrievalClient) RemoveAllActiveGateways

func (c *FilecoinRetrievalClient) RemoveAllActiveGateways() int

RemoveAllActiveGateways removes all gateways from the list of Gateways in active.

func (*FilecoinRetrievalClient) RemoveAllGatewaysToUse

func (c *FilecoinRetrievalClient) RemoveAllGatewaysToUse() int

RemoveAllGatewaysToUse removes all gateways from the list of Gateways. This also cleared all gateways in active

func (*FilecoinRetrievalClient) RemoveGatewaysToUse

func (c *FilecoinRetrievalClient) RemoveGatewaysToUse(gwNodeIDs []*nodeid.NodeID) int

RemoveGatewaysToUse removes one or more gateways from the list of Gateways to use. This also removes the gateway from gateways in active map.

type SettingsBuilder

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

SettingsBuilder holds the library configuration

func CreateSettings

func CreateSettings() *SettingsBuilder

CreateSettings creates an object with the default settings.

func (*SettingsBuilder) Build

func (f *SettingsBuilder) Build() *ClientSettings

Build creates a settings object and initialises the logging system.

func (*SettingsBuilder) SetBlockchainPrivateKey

func (f *SettingsBuilder) SetBlockchainPrivateKey(bcPkey *fcrcrypto.KeyPair)

SetBlockchainPrivateKey sets the blockchain private key.

func (*SettingsBuilder) SetEstablishmentTTL

func (f *SettingsBuilder) SetEstablishmentTTL(ttl int64)

SetEstablishmentTTL sets the time to live for the establishment message between client and gateway.

func (*SettingsBuilder) SetLogging

func (f *SettingsBuilder) SetLogging(logLevel string, logTarget string, logServiceName string)

SetLogging sets the log level and target.

func (*SettingsBuilder) SetLotusAP

func (f *SettingsBuilder) SetLotusAP(lotusAP string)

func (*SettingsBuilder) SetLotusAuthToken

func (f *SettingsBuilder) SetLotusAuthToken(lotusAuthToken string)

func (*SettingsBuilder) SetOfferPrice

func (f *SettingsBuilder) SetOfferPrice(offerPrice *big.Int)

func (*SettingsBuilder) SetRegisterURL

func (f *SettingsBuilder) SetRegisterURL(url string)

SetRegisterURL sets the register URL.

func (*SettingsBuilder) SetRetrievalPrivateKey

func (f *SettingsBuilder) SetRetrievalPrivateKey(rPkey *fcrcrypto.KeyPair, ver *fcrcrypto.KeyVersion)

SetRetrievalPrivateKey sets the retrieval private key.

func (*SettingsBuilder) SetSearchPrice

func (f *SettingsBuilder) SetSearchPrice(searchPrice *big.Int)

func (*SettingsBuilder) SetTopUpAmount

func (f *SettingsBuilder) SetTopUpAmount(topUpAmount *big.Int)

func (*SettingsBuilder) SetWalletPrivateKey

func (f *SettingsBuilder) SetWalletPrivateKey(walletPrivateKey string)

type VersionInfo

type VersionInfo struct {
	Version   string
	BuildDate string
}

VersionInfo holds the version information for the Filecoin Retrieval Client library.

func GetVersion

func GetVersion() VersionInfo

GetVersion returns the static build information.

Jump to

Keyboard shortcuts

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