Documentation
¶
Overview ¶
Package rtfs is a helper library for interacting with IPFS and IPFS keys. It is used by [Temporal](https://github.com/RTradeLtd/Temporal), an easy-to-use interface into distributed and decentralized storage technologies for personal and enterprise use cases.
Index ¶
- func DedupAndCalculatePinSize(hash string, im Manager) (int64, []string, error)
- func MnemonicToKey(phrase string) (ci.PrivKey, error)
- type IpfsManager
- func (im *IpfsManager) Add(r io.Reader, options ...ipfsapi.AddOpts) (string, error)
- func (im *IpfsManager) AddDir(dir string) (string, error)
- func (im *IpfsManager) AppendData(root string, data interface{}) (string, error)
- func (im *IpfsManager) Cat(cid string) ([]byte, error)
- func (im *IpfsManager) CheckPin(hash string) (bool, error)
- func (im *IpfsManager) CustomRequest(ctx context.Context, url, commad string, opts map[string]string, ...) (*ipfsapi.Response, error)
- func (im *IpfsManager) DagGet(cid string, out interface{}) error
- func (im *IpfsManager) DagPut(data interface{}, encoding, kind string) (string, error)
- func (im *IpfsManager) DeduplicatedSize(hash string) (int, error)
- func (im *IpfsManager) GetLogs(ctx context.Context) (ipfsapi.Logger, error)
- func (im *IpfsManager) NewObject(template string) (string, error)
- func (im *IpfsManager) NodeAddress() string
- func (im *IpfsManager) PatchLink(root, path, childHash string, create bool) (string, error)
- func (im *IpfsManager) Pin(hash string) error
- func (im *IpfsManager) PinUpdate(from, to string) (string, error)
- func (im *IpfsManager) PubSubPublish(topic string, data string) error
- func (im *IpfsManager) Publish(contentHash, keyName string, lifetime, ttl time.Duration, resolve bool) (*ipfsapi.PublishResponse, error)
- func (im *IpfsManager) Refs(hash string, recursive, unique bool) ([]string, error)
- func (im *IpfsManager) Resolve(hash string) (string, error)
- func (im *IpfsManager) SetData(root string, data interface{}) (string, error)
- func (im *IpfsManager) Stat(hash string) (*ipfsapi.ObjectStats, error)
- func (im *IpfsManager) SwarmConnect(ctx context.Context, addrs ...string) error
- type KeystoreManager
- func (km *KeystoreManager) CheckIfKeyExists(keyName string) (bool, error)
- func (km *KeystoreManager) CreateAndSaveKey(keyName string, keyType, bits int) (ci.PrivKey, error)
- func (km *KeystoreManager) ExportKeyAsMnemonic(keyName string) (string, error)
- func (km *KeystoreManager) GetPrivateKeyByName(keyName string) (ci.PrivKey, error)
- func (km *KeystoreManager) ListKeyIdentifiers() ([]string, error)
- func (km *KeystoreManager) SavePrivateKey(keyName string, pk ci.PrivKey) error
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DedupAndCalculatePinSize ¶
DedupAndCalculatePinSize is used to remove duplicate refers to objects for a more accurate pin size cost it returns the size of all refs, as well as all unique references
Types ¶
type IpfsManager ¶
type IpfsManager struct {
// contains filtered or unexported fields
}
IpfsManager is our helper wrapper for IPFS
func NewManager ¶
func NewManager(ipfsURL, token string, timeout time.Duration) (*IpfsManager, error)
NewManager is used to instantiate IpfsManager with a connection to an ipfs api. if token is provided, we use it to establish an authentication, direct connection to an ipfs node api, which involves skipping multiaddr parsing. This is useful in situations such as interacting with Nexus' delegator to talk with private ipfs networks which use non-standard connection methods.
func (*IpfsManager) AddDir ¶
func (im *IpfsManager) AddDir(dir string) (string, error)
AddDir is used to add a directory to ipfs
func (*IpfsManager) AppendData ¶
func (im *IpfsManager) AppendData(root string, data interface{}) (string, error)
AppendData is used to modify the raw data within an object, to a max of 1MB Anything larger than 1MB will not be respected by the rest of the network
func (*IpfsManager) Cat ¶
func (im *IpfsManager) Cat(cid string) ([]byte, error)
Cat is used to get cat an ipfs object
func (*IpfsManager) CheckPin ¶
func (im *IpfsManager) CheckPin(hash string) (bool, error)
CheckPin checks whether or not a pin is present
func (*IpfsManager) CustomRequest ¶
func (im *IpfsManager) CustomRequest(ctx context.Context, url, commad string, opts map[string]string, args ...string) (*ipfsapi.Response, error)
CustomRequest is used to make a custom request
func (*IpfsManager) DagGet ¶
func (im *IpfsManager) DagGet(cid string, out interface{}) error
DagGet is used to get an ipld object
func (*IpfsManager) DagPut ¶
func (im *IpfsManager) DagPut(data interface{}, encoding, kind string) (string, error)
DagPut is used to store data as an ipld object
func (*IpfsManager) DeduplicatedSize ¶ added in v2.3.0
func (im *IpfsManager) DeduplicatedSize(hash string) (int, error)
DeduplicatedSize will calculate the deduplicated size of an object. This is limited to UnixFS object types
func (*IpfsManager) GetLogs ¶ added in v2.1.1
GetLogs is used to return a logger for the IPFS HTTP API call log/tail
func (*IpfsManager) NewObject ¶
func (im *IpfsManager) NewObject(template string) (string, error)
NewObject is used to create a generic object from a template type
func (*IpfsManager) NodeAddress ¶
func (im *IpfsManager) NodeAddress() string
NodeAddress returns the node the manager is connected to
func (*IpfsManager) PatchLink ¶
func (im *IpfsManager) PatchLink(root, path, childHash string, create bool) (string, error)
PatchLink is used to link two objects together path really means the name of the link create is used to specify whether intermediary nodes should be generated
func (*IpfsManager) Pin ¶
func (im *IpfsManager) Pin(hash string) error
Pin is a wrapper method to pin a hash. pinning prevents GC and persistently stores on disk
func (*IpfsManager) PinUpdate ¶
func (im *IpfsManager) PinUpdate(from, to string) (string, error)
PinUpdate is used to update one pin to another, while making sure all objects in the new pin are local, followed by removing the old pin.
This is an optimized version of pinning the new content, and then removing the old content.
returns the new pin path
func (*IpfsManager) PubSubPublish ¶
func (im *IpfsManager) PubSubPublish(topic string, data string) error
PubSubPublish is used to publish a a message to the given topic
func (*IpfsManager) Publish ¶
func (im *IpfsManager) Publish(contentHash, keyName string, lifetime, ttl time.Duration, resolve bool) (*ipfsapi.PublishResponse, error)
Publish is used for fine grained control over IPNS record publishing
func (*IpfsManager) Refs ¶
func (im *IpfsManager) Refs(hash string, recursive, unique bool) ([]string, error)
Refs is used to retrieve references of a hash
func (*IpfsManager) Resolve ¶
func (im *IpfsManager) Resolve(hash string) (string, error)
Resolve is used to resolve an IPNS hash
func (*IpfsManager) SetData ¶
func (im *IpfsManager) SetData(root string, data interface{}) (string, error)
SetData is used to set the data field of an ipfs object
func (*IpfsManager) Stat ¶
func (im *IpfsManager) Stat(hash string) (*ipfsapi.ObjectStats, error)
Stat is used to retrieve the stats about an object
func (*IpfsManager) SwarmConnect ¶
func (im *IpfsManager) SwarmConnect(ctx context.Context, addrs ...string) error
SwarmConnect is use to open a connection a one or more ipfs nodes
type KeystoreManager ¶
type KeystoreManager struct {
// contains filtered or unexported fields
}
KeystoreManager is howe we manipulat keys
func NewKeystoreManager ¶
func NewKeystoreManager(store *krab.Keystore) (*KeystoreManager, error)
NewKeystoreManager instantiates a new keystore manager. Takes an optional filepath for the store.
func (*KeystoreManager) CheckIfKeyExists ¶
func (km *KeystoreManager) CheckIfKeyExists(keyName string) (bool, error)
CheckIfKeyExists is used to check if a key exists
func (*KeystoreManager) CreateAndSaveKey ¶
CreateAndSaveKey is used to create a key of the given type and size
func (*KeystoreManager) ExportKeyAsMnemonic ¶
func (km *KeystoreManager) ExportKeyAsMnemonic(keyName string) (string, error)
ExportKeyAsMnemonic is used to take an IPFS key, and return a human-readable friendly version. The idea is to allow users to easily export the keys they create, allowing them to take control of their records (ipns, tns, etc..)
func (*KeystoreManager) GetPrivateKeyByName ¶
func (km *KeystoreManager) GetPrivateKeyByName(keyName string) (ci.PrivKey, error)
GetPrivateKeyByName is used to get a private key by its name
func (*KeystoreManager) ListKeyIdentifiers ¶
func (km *KeystoreManager) ListKeyIdentifiers() ([]string, error)
ListKeyIdentifiers will list out all key IDs (aka, public hashes)
func (*KeystoreManager) SavePrivateKey ¶
func (km *KeystoreManager) SavePrivateKey(keyName string, pk ci.PrivKey) error
SavePrivateKey is used to save a private key under the specified name
type Manager ¶
type Manager interface { // NodeAddress returns the node the manager is connected to NodeAddress() string // Add is a wrapper used to add a file to IPFS Add(r io.Reader, options ...ipfsapi.AddOpts) (string, error) // AddDir is used to add a directory to ipfs AddDir(dir string) (string, error) // DagPut is used to store data as an ipld object DagPut(data interface{}, encoding, kind string) (string, error) // DagGet is used to get an ipld object DagGet(cid string, out interface{}) error // Cat is used to get cat an ipfs object Cat(cid string) ([]byte, error) // Stat is used to retrieve the stats about an object Stat(hash string) (*ipfsapi.ObjectStats, error) // PatchLink is used to link two objects together // path really means the name of the link // create is used to specify whether intermediary nodes should be generated PatchLink(root, path, childHash string, create bool) (string, error) // AppendData is used to modify the raw data within an object, to a max of 1MB // Anything larger than 1MB will not be respected by the rest of the network AppendData(root string, data interface{}) (string, error) // SetData is used to set the data field of an ipfs object SetData(root string, data interface{}) (string, error) // NewObject is used to create a generic object from a template type NewObject(template string) (string, error) // Pin is a wrapper method to pin a hash. // pinning prevents GC and persistently stores on disk Pin(hash string) error // PinUpdate is used to update one pin to another, while making sure all objects // in the new pin are local, followed by removing the old pin. // // This is an optimized version of pinning the new content, and then removing the // old content. // // returns the new pin path PinUpdate(from, to string) (string, error) // CheckPin checks whether or not a pin is present CheckPin(hash string) (bool, error) // Publish is used for fine grained control over IPNS record publishing Publish(contentHash, keyName string, lifetime, ttl time.Duration, resolve bool) (*ipfsapi.PublishResponse, error) // Resolve is used to resolve an IPNS hash Resolve(hash string) (string, error) // PubSubPublish is used to publish a a message to the given topic PubSubPublish(topic string, data string) error // CustomRequest is used to make a custom request CustomRequest(ctx context.Context, url, commad string, opts map[string]string, args ...string) (*ipfsapi.Response, error) // GetLogs is used to return a logger for the IPFS HTTP API call log/tail GetLogs(ctx context.Context) (ipfsapi.Logger, error) // SwarmConnect is use to open a connection a one or more ipfs nodes SwarmConnect(ctx context.Context, addrs ...string) error // Refs is used to retrieve references of a hash Refs(hash string, recursive, unique bool) ([]string, error) // DeduplicatedSize will calculate the deduplicated size of an object. // This is limited to UnixFS object types DeduplicatedSize(hash string) (int, error) }
Manager provides functions for interacting with IPFS