ipfs

package
v0.0.0-...-d0dabfa Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const CatTimeout = 20 * time.Minute
View Source
const ConnectTimeout = time.Second * 5 //from 10 to 5 2019.11.27
View Source
const DefaultTimeout = time.Second * 2 //from 5 to 2 2019.11.27
View Source
const PinTimeout = 5 * time.Minute
View Source
const PublishTimeout = time.Second * 5

Variables

This section is empty.

Functions

func AddData

func AddData(node *core.IpfsNode, reader io.Reader, pin bool, hashOnly bool) (*icid.Cid, error)

AddData takes a reader and adds it, optionally pins it, optionally only hashes it

func AddDataToDirectory

func AddDataToDirectory(node *core.IpfsNode, dir uio.Directory, fname string, reader io.Reader) (*icid.Cid, error)

AddDataToDirectory adds reader bytes to a virtual dir

func AddFolder

func AddFolder(node *core.IpfsNode, path string, pin bool) (*icid.Cid, error)

func AddLinkToDirectory

func AddLinkToDirectory(node *core.IpfsNode, dir uio.Directory, fname string, pth string) error

AddLinkToDirectory adds a link to a virtual dir

func AddObject

func AddObject(node *core.IpfsNode, reader io.Reader, pin bool) (*icid.Cid, error)

AddObject takes a reader and adds it as a DAG node, optionally pins it

func ComparePath

func ComparePath(node *core.IpfsNode, pth1 string, pth2 string) (int, int, int, int, int, error)

Note that ComparePath would not fetch or pin the cid. return

  • number of cids in first path
  • number of cids in second path
  • number of same cids
  • number of A minus B
  • number of B minus A
  • error

func ConnectToTopicReceiver

func ConnectToTopicReceiver(node *core.IpfsNode, ctx context.Context, topic string) error

func DataAtPath

func DataAtPath(node *core.IpfsNode, pth string) ([]byte, error)

DataAtPath return bytes under an ipfs path

func FilePathAtIpfsPath

func FilePathAtIpfsPath(node *core.IpfsNode, pth string, repoPath string) (string, error)

func FolderAtPath

func FolderAtPath(node *core.IpfsNode, pth string, repoPath string) (string, error)

func GetBlock

func GetBlock(node *core.IpfsNode, p path.Path) (io.Reader, error)

func GetIPv6Addr

func GetIPv6Addr(node *core.IpfsNode) (string, error)

GetIPv6Addr returns the ipv6 address of the host machine, if available

func GetLANIPv4Addr

func GetLANIPv4Addr(node *core.IpfsNode) (string, error)

GetLANIPv4Addr looks for a LAN IP in the host addresses (192.168.x.x)

func GetPublicIPv4Addr

func GetPublicIPv4Addr(node *core.IpfsNode) (string, error)

GetPublicIPv4Addr uses the host addresses to return the public ipv4 address of the host machine, if available

func IdentityConfig

func IdentityConfig(sk libp2pc.PrivKey) (config.Identity, error)

IdentityConfig initializes a new identity.

func IpnsSubs

func IpnsSubs(node *core.IpfsNode) ([]string, error)

IpnsSubs shows current name subscriptions

func LinksAtPath

func LinksAtPath(node *core.IpfsNode, pth string) ([]*ipld.Link, error)

LinksAtPath return ipld links under a path

func ListCids

func ListCids(node *core.IpfsNode, cid string) ([]string, error)

traverse node according to cid and return all the cids belonging to it.

func ListSortCids

func ListSortCids(node *core.IpfsNode, cid string) ([]string, error)

func NodeAtCid

func NodeAtCid(node *core.IpfsNode, id icid.Cid) (ipld.Node, error)

NodeAtCid returns the node behind a cid

func NodeAtLink(node *core.IpfsNode, link *ipld.Link) (ipld.Node, error)

NodeAtLink returns the node behind an ipld link

func NodeAtPath

func NodeAtPath(node *core.IpfsNode, pth string, timeout time.Duration) (ipld.Node, error)

NodeAtPath returns the last node under path

func NotPinned

func NotPinned(node *core.IpfsNode, cids []string) ([]icid.Cid, error)

NotPinned returns the subset of given cids that are not pinned

func ObjectAtPath

func ObjectAtPath(node *core.IpfsNode, pth string) ([]byte, error)

ObjectAtPath returns the DAG object at the given path

func PinNode

func PinNode(node *core.IpfsNode, nd ipld.Node, recursive bool) error

PinNode pins an ipld node

func Pinned

func Pinned(node *core.IpfsNode, cids []string) ([]icid.Cid, error)

Pinned returns the subset of given cids that are pinned

func PrintSwarmAddrs

func PrintSwarmAddrs(node *core.IpfsNode) error

PrintSwarmAddrs prints the addresses of the host

func Publish

func Publish(node *core.IpfsNode, topic string, data []byte) error

Publish publishes data to a topic

func PublishIPNS

func PublishIPNS(node *core.IpfsNode, id string, key string, timeout time.Duration) (iface.IpnsEntry, error)

PublishIPNS publishes a content id to ipns

func PutBlock

func PutBlock(node *core.IpfsNode, src io.Reader) (iface.BlockStat, error)

func ResolveIPNS

func ResolveIPNS(node *core.IpfsNode, name peer.ID, timeout time.Duration) (path.Path, error)

ResolveIPNS resolves an ipns path to an ipfs path

func ResolveLinkByNames

func ResolveLinkByNames(nd ipld.Node, names []string) (*ipld.Link, error)

ResolveLinkByNames resolves a link in a node from a list of valid names Note: This exists for b/c w/ the "f" -> "meta" and "d" -> content migration

func ShortenID

func ShortenID(id string) string

ShortenID returns the last 7 chars of a string

func StatObjectAtPath

func StatObjectAtPath(node *core.IpfsNode, pth string) (*iface.ObjectStat, error)

StatObjectAtPath returns info about an object

func Subscribe

func Subscribe(node *core.IpfsNode, ctx context.Context, topic string, discover bool, msgs chan iface.PubSubMessage) error

Subscribe subscribes to a topic

func SwarmConnect

func SwarmConnect(node *core.IpfsNode, addrs []string) ([]string, error)

SwarmConnect opens a direct connection to a list of peer multi addresses

func SwarmConnected

func SwarmConnected(node *core.IpfsNode, peerId string) (bool, error)

SwarmConnected returns whether or not the node has the peer in its current swarm

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (libp2pc.PrivKey, error)

UnmarshalPrivateKey converts a protobuf serialized private key into its representative object

func UnmarshalPrivateKeyFromString

func UnmarshalPrivateKeyFromString(key string) (libp2pc.PrivKey, error)

UnmarshalPrivateKeyFromString attempts to create a private key from a base64 encoded string

func UnmarshalPublicKeyFromString

func UnmarshalPublicKeyFromString(key string) (libp2pc.PubKey, error)

UnmarshalPublicKeyFromString attempts to create a public key from a base64 encoded string

func UnpinCid

func UnpinCid(node *core.IpfsNode, id icid.Cid, recursive bool) error

UnpinCid unpins a cid

func UnpinNode

func UnpinNode(node *core.IpfsNode, nd ipld.Node, recursive bool) error

UnpinNode unpins an ipld node

Types

type ConnInfos

type ConnInfos struct {
	Peers []connInfo `json:"peers"`
}

func SwarmPeers

func SwarmPeers(node *core.IpfsNode, verbose bool, latency bool, streams bool, direction bool) (*ConnInfos, error)

SwarmPeers lists the set of peers this node is connected to

func (ConnInfos) Len

func (ci ConnInfos) Len() int

func (ConnInfos) Less

func (ci ConnInfos) Less(i, j int) bool

func (ConnInfos) Swap

func (ci ConnInfos) Swap(i, j int)
type Link struct {
	Name, Hash string
	Size       uint64
}

type Node

type Node struct {
	Links []Link
	Data  string
}

Jump to

Keyboard shortcuts

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