ipfs

package
v0.7.2-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2017 License: MIT Imports: 46 Imported by: 132

Documentation

Index

Constants

View Source
const CatTimeout = 30 * time.Second
View Source
const MAGIC string = "000000000000000000000000"
View Source
const ResolveTimeout = 30 * time.Second

Variables

View Source
var Root = &cmds.Command{
	Options:  commands.Root.Options,
	Helptext: commands.Root.Helptext,
}

Functions

func AddDirectory

func AddDirectory(ctx commands.Context, fpath string) (rootHash string, err error)

Resursively add a directory to IPFS and return the root hash

func AddFile

func AddFile(ctx commands.Context, fpath string) (string, error)

func Cat

func Cat(ctx commands.Context, hash string) ([]byte, error)

Fetch data from IPFS given the hash

func ConnectedPeers

func ConnectedPeers(ctx commands.Context) ([]string, error)

func CreatePointerKey added in v0.6.3

func CreatePointerKey(mh multihash.Multihash, prefixLen int) multihash.Multihash

func FindPointers

func FindPointers(dht *routing.IpfsDHT, ctx context.Context, mhKey multihash.Multihash, prefixLen int) ([]ps.PeerInfo, error)

Fetch pointers from the dht

func FindPointersAsync

func FindPointersAsync(dht *routing.IpfsDHT, ctx context.Context, mhKey multihash.Multihash, prefixLen int) <-chan ps.PeerInfo

Fetch pointers from the dht. They will be returned asynchronously.

func GetHash added in v0.4.3

func GetHash(ctx commands.Context, reader io.Reader) (string, error)

func GetHashOfFile added in v0.5.5

func GetHashOfFile(ctx commands.Context, fpath string) (string, error)

func IdentityFromKey

func IdentityFromKey(privkey []byte) (config.Identity, error)

func IdentityKeyFromSeed

func IdentityKeyFromSeed(seed []byte, bits int) ([]byte, error)

func MockCmdsCtx

func MockCmdsCtx() (commands.Context, error)

func MockHostOption

func MockHostOption(mn mocknet.Mocknet) core.HostOption

func NewMockNode

func NewMockNode() (*core.IpfsNode, error)

NewMockNode constructs an IpfsNode for use in tests.

func NewRequest

func NewRequest(ctx cmds.Context, args []string) (cmds.Request, *cmds.Command, error)

func NewRequestWithTimeout added in v0.1.1

func NewRequestWithTimeout(ctx cmds.Context, args []string, timeout time.Duration) (cmds.Request, *cmds.Command, error)

func Publish

func Publish(ctx commands.Context, hash string) (string, error)

Publish a signed IPNS record to our Peer ID

func Query

func Query(ctx commands.Context, peerID string) ([]peer.ID, error)

func RePublishPointer

func RePublishPointer(node *core.IpfsNode, ctx context.Context, pointer Pointer) error

func Resolve added in v0.1.1

func Resolve(ctx commands.Context, hash string) (string, error)

Publish a signed IPNS record to our Peer ID

func ResolveThenCat added in v0.1.1

func ResolveThenCat(ctx commands.Context, ipnsPath path.Path) ([]byte, error)

func UnPinDir

func UnPinDir(ctx commands.Context, rootHash string) error

Recursively un-pin a directory given its hash.

This will allow it to be garbage collected.

Types

type Pointer

type Pointer struct {
	Cid       *cid.Cid
	Value     ps.PeerInfo
	Purpose   Purpose
	Timestamp time.Time
	CancelID  *peer.ID
}

A pointer is a custom provider inserted into the DHT which points to a location of a file.

For offline messaging purposes we use a hash of the recipient's ID as the key and set the
provider to the location of the ciphertext. We set the Peer ID of the provider object to
a magic number so we distinguish it from regular providers and use a longer ttl.
Note this will only be compatible with the OpenBazaar/go-ipfs fork.

func PublishPointer

func PublishPointer(node *core.IpfsNode, ctx context.Context, mhKey multihash.Multihash, prefixLen int, addr ma.Multiaddr, entropy []byte) (Pointer, error)

entropy is a sequence of bytes that should be deterministic based on the content of the pointer it is hashed and used to fill the remaining 20 bytes of the magic id

type Purpose

type Purpose int
const (
	MESSAGE   Purpose = 1
	MODERATOR Purpose = 2
	TAG       Purpose = 3
	CHANNEL   Purpose = 4
)

Jump to

Keyboard shortcuts

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