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 ¶
- type ClientSettings
- func (c ClientSettings) BlockchainPrivateKey() *fcrcrypto.KeyPair
- func (c ClientSettings) ClientID() *nodeid.NodeID
- func (c ClientSettings) EstablishmentTTL() int64
- func (c ClientSettings) LotusAP() string
- func (c ClientSettings) LotusAuthToken() string
- func (c ClientSettings) OfferPrice() *big.Int
- func (c ClientSettings) RegisterURL() string
- func (c ClientSettings) RetrievalPrivateKey() *fcrcrypto.KeyPair
- func (c ClientSettings) RetrievalPrivateKeyVer() *fcrcrypto.KeyVersion
- func (c ClientSettings) SearchPrice() *big.Int
- func (c ClientSettings) TopUpAmount() *big.Int
- func (c ClientSettings) WalletPrivateKey() string
- type FilecoinRetrievalClient
- func (c *FilecoinRetrievalClient) AddActiveGateways(gwNodeIDs []*nodeid.NodeID) int
- func (c *FilecoinRetrievalClient) AddGatewaysToUse(gwNodeIDs []*nodeid.NodeID) int
- func (c *FilecoinRetrievalClient) FindDHTOfferAck(contentID *cid.ContentID, gatewayID *nodeid.NodeID, providerID *nodeid.NodeID) (bool, error)
- func (c *FilecoinRetrievalClient) FindGateways(location string, maxNumToLocate int) ([]*nodeid.NodeID, error)
- func (c *FilecoinRetrievalClient) FindOffersDHTDiscovery(contentID *cid.ContentID, gatewayID *nodeid.NodeID, numDHT int64) (map[string]*[]cidoffer.SubCIDOffer, error)
- func (c *FilecoinRetrievalClient) FindOffersDHTDiscoveryV2(contentID *cid.ContentID, gatewayID *nodeid.NodeID, numDHT int64, ...) (map[string]*[]cidoffer.SubCIDOffer, error)
- func (c *FilecoinRetrievalClient) FindOffersStandardDiscovery(contentID *cid.ContentID, gatewayID *nodeid.NodeID) ([]cidoffer.SubCIDOffer, error)
- func (c *FilecoinRetrievalClient) FindOffersStandardDiscoveryV2(contentID *cid.ContentID, gatewayID *nodeid.NodeID, maxOffers int) ([]cidoffer.SubCIDOffer, error)
- func (c *FilecoinRetrievalClient) GetActiveGateways() []*nodeid.NodeID
- func (c *FilecoinRetrievalClient) GetGatewaysToUse() []*nodeid.NodeID
- func (c *FilecoinRetrievalClient) PaymentMgr() *fcrpaymentmgr.FCRPaymentMgr
- func (c *FilecoinRetrievalClient) RemoveActiveGateways(gwNodeIDs []*nodeid.NodeID) int
- func (c *FilecoinRetrievalClient) RemoveAllActiveGateways() int
- func (c *FilecoinRetrievalClient) RemoveAllGatewaysToUse() int
- func (c *FilecoinRetrievalClient) RemoveGatewaysToUse(gwNodeIDs []*nodeid.NodeID) int
- type SettingsBuilder
- func (f *SettingsBuilder) Build() *ClientSettings
- func (f *SettingsBuilder) SetBlockchainPrivateKey(bcPkey *fcrcrypto.KeyPair)
- func (f *SettingsBuilder) SetEstablishmentTTL(ttl int64)
- func (f *SettingsBuilder) SetLogging(logLevel string, logTarget string, logServiceName string)
- func (f *SettingsBuilder) SetLotusAP(lotusAP string)
- func (f *SettingsBuilder) SetLotusAuthToken(lotusAuthToken string)
- func (f *SettingsBuilder) SetOfferPrice(offerPrice *big.Int)
- func (f *SettingsBuilder) SetRegisterURL(url string)
- func (f *SettingsBuilder) SetRetrievalPrivateKey(rPkey *fcrcrypto.KeyPair, ver *fcrcrypto.KeyVersion)
- func (f *SettingsBuilder) SetSearchPrice(searchPrice *big.Int)
- func (f *SettingsBuilder) SetTopUpAmount(topUpAmount *big.Int)
- func (f *SettingsBuilder) SetWalletPrivateKey(walletPrivateKey string)
- type VersionInfo
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 (c *FilecoinRetrievalClient) PaymentMgr() *fcrpaymentmgr.FCRPaymentMgr
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 ¶
VersionInfo holds the version information for the Filecoin Retrieval Client library.