Documentation ¶
Overview ¶
Package ipfs wraps the ipfs core api with some useful client methods for PubSub and IO.
Index ¶
- Constants
- Variables
- type Client
- func (client *Client) AddFile(ctx context.Context, filePath string, pinning bool) (string, error)
- func (client *Client) AddLink(ctx context.Context, baseCID, childCID, linkLabel string) (string, error)
- func (client *Client) Connect(ctx context.Context, peers []string, logger chan interface{})
- func (client *Client) DagGet(ctx context.Context, queryCID string) (interface{}, error)
- func (client *Client) DagPut(ctx context.Context, data []byte, pinning bool) (string, error)
- func (client *Client) EndSession() error
- func (client *Client) GetFile(ctx context.Context, cidStr, outputPath string) error
- func (client *Client) GetNodeData(ctx context.Context, nodeCID string) (io.Reader, error)
- func (client *Client) GetNodeLinks(ctx context.Context, nodeCID string) ([]*ipld.Link, error)
- func (client *Client) GetPSEchan() chan error
- func (client *Client) GetPSMchan() chan icore.PubSubMessage
- func (client *Client) GetPeers(ctx context.Context) ([]string, error)
- func (client *Client) GetPublicIPv4Addr() (string, error)
- func (client *Client) NewDagNode(ctx context.Context) (string, error)
- func (client *Client) Online() bool
- func (client *Client) PrintNodeID() string
- func (client *Client) RmLink(ctx context.Context, baseCID, linkLabel string) (string, error)
- func (client *Client) SendMessage(ctx context.Context, topic string, message []byte) error
- func (client *Client) Subscribe(ctx context.Context, topic string) error
- func (client *Client) Unpin(ctx context.Context, cidStr string) error
- func (client *Client) Unsubscribe() error
Constants ¶
const ( // DefaultBufferSize is used in the buffered PubSub channels. DefaultBufferSize = 42 // DefaultIenc is the input encoding for the data will be added to the IPFS DAG. DefaultIenc = "json" // DefaultFormatParser is the format of the input data for IPFS. DefaultFormatParser = "cbor" // DefaultMhType is the multihash to use for DAG put operations. DefaultMhType = uint64(math.MaxUint64) // use default hash (sha256 for cbor, sha1 for git..) )
Variables ¶
var ( // DefaultBootstrappers are nodes used for IPFS peer discovery. DefaultBootstrappers = []string{ "/ip4/138.201.67.219/tcp/4001/p2p/QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA", "/ip4/138.201.67.219/udp/4001/quic/p2p/QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA", "/ip4/138.201.67.220/tcp/4001/p2p/QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i", "/ip4/138.201.67.220/udp/4001/quic/p2p/QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i", "/ip4/138.201.68.74/tcp/4001/p2p/QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR", "/ip4/138.201.68.74/udp/4001/quic/p2p/QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR", "/ip4/94.130.135.167/tcp/4001/p2p/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE", "/ip4/94.130.135.167/udp/4001/quic/p2p/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE", } // ErrRepoAlreadyInitialised is issued when an IPFS repo has already been initialised. ErrRepoAlreadyInitialised = fmt.Errorf("specified IPFS repo is already initialised") // ErrNoLinks is issued when no links are found in an IPFS DAG node. ErrNoLinks = fmt.Errorf("no links found in IPFS DAG node") // ErrOffline indicates node is offline. ErrOffline = fmt.Errorf("the IPFS node is offline") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper that groups and controls access to the IPFS for the starkDB.
func NewIPFSclient ¶
NewIPFSclient will initialise the IPFS client.
The IPFS code used in starkDB is based on the IPFS as a library example (go-ipfs v0.5.0)
Note: if no repoPath provided, this function will attempt to use the IPFS default repo path.
func (*Client) AddLink ¶
func (client *Client) AddLink(ctx context.Context, baseCID, childCID, linkLabel string) (string, error)
AddLink will add a link under the specified path. Child path can point to a subdirectory within the patent, it will be created if not present. It will return the new base CID and any error.
func (*Client) Connect ¶
Connect will connect the client to peers. It is adapted from https://github.com/ipfs/go-ipfs/tree/master/docs/examples/go-ipfs-as-a-library
func (*Client) EndSession ¶
EndSession closes down the client.
func (*Client) GetFile ¶
GetFile will get a file (or directory) from the IPFS using the supplied CID and then write it to the supplied outputPath.
func (*Client) GetNodeData ¶
GetNodeData will output a reader for the raw bytes contained in an IPFS DAG node.
func (*Client) GetNodeLinks ¶
GetNodeLinks returns the links from a node.
func (*Client) GetPSEchan ¶
GetPSEchan gives access to the PubSub errors channel.
func (*Client) GetPSMchan ¶
func (client *Client) GetPSMchan() chan icore.PubSubMessage
GetPSMchan gives access to the PubSub messages channel.
func (*Client) GetPublicIPv4Addr ¶
GetPublicIPv4Addr uses the host addresses to return the public ipv4 address of the host machine, if available.
func (*Client) NewDagNode ¶
NewDagNode will create a new UNIXFS formatted DAG node in the IPFS.
func (*Client) PrintNodeID ¶
PrintNodeID will print the node's identity.
func (*Client) RmLink ¶
RmLink will remove a link under the specified path. It will return the new base CID and any error.
func (*Client) SendMessage ¶
SendMessage will broadcast a message via PubSub.
func (*Client) Subscribe ¶
Subscribe will start a Client's PubSub subscription for the provided topic.
Note: see https://blog.ipfs.io/25-pubsub/ for good intro on PubSub
func (*Client) Unsubscribe ¶
Unsubscribe will stop a Client's active PubSub subscription.