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) 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 ΒΆ added in v0.2.0
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) 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 ΒΆ added in v0.2.0
func NewKeystoreManager(store *krab.Krab) (*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 ΒΆ added in v0.2.0
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) // 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) }
Manager provides functions for interacting with IPFS