Documentation ¶
Index ¶
- Constants
- Variables
- func AddDirectory(ctx commands.Context, fpath string) (rootHash string, err error)
- func AddFile(ctx commands.Context, fpath string) (string, error)
- func Cat(ctx commands.Context, hash string) ([]byte, error)
- func ConnectedPeers(ctx commands.Context) ([]string, error)
- func CreatePointerKey(mh multihash.Multihash, prefixLen int) multihash.Multihash
- func FetchGraph(dag merkledag.DAGService, id *cid.Cid) ([]cid.Cid, error)
- func FindPointers(ctx context.Context, dht *routing.IpfsDHT, mhKey multihash.Multihash, ...) ([]ps.PeerInfo, error)
- func FindPointersAsync(ctx context.Context, dht *routing.IpfsDHT, mhKey multihash.Multihash, ...) <-chan ps.PeerInfo
- func GetHash(ctx commands.Context, reader io.Reader) (string, error)
- func GetHashOfFile(ctx commands.Context, fpath string) (string, error)
- func GetPointersFromPeer(node *core.IpfsNode, ctx context.Context, p peer.ID, key *cid.Cid) ([]*ps.PeerInfo, error)
- func IdentityFromKey(privkey []byte) (config.Identity, error)
- func IdentityKeyFromSeed(seed []byte, bits int) ([]byte, error)
- func MockCmdsCtx() (commands.Context, error)
- func MockHostOption(mn mocknet.Mocknet) core.HostOption
- func NewMockNode() (*core.IpfsNode, error)
- func NewRequest(ctx cmds.Context, args []string) (cmds.Request, *cmds.Command, error)
- func NewRequestWithTimeout(ctx cmds.Context, args []string, timeout time.Duration) (cmds.Request, *cmds.Command, error)
- func Publish(ctx commands.Context, hash string) (string, error)
- func PublishPointer(ctx context.Context, node *core.IpfsNode, pointer Pointer) error
- func PutPointerToPeer(node *core.IpfsNode, ctx context.Context, peer peer.ID, pointer Pointer) error
- func Query(ctx commands.Context, peerID string) ([]peer.ID, error)
- func Resolve(ctx commands.Context, hash string) (string, error)
- func ResolveThenCat(ctx commands.Context, ipnsPath path.Path) ([]byte, error)
- func UnPinDir(ctx commands.Context, rootHash string) error
- type Pointer
- type Purpose
Constants ¶
const CatTimeout = 60 * time.Second
const MAGIC string = "000000000000000000000000"
MAGIC is a constant combined with a hashed key when creating a magic ID.
const ResolveTimeout = 30 * time.Second
ResolveTimeout sets the timeout value for resolving the name of a signed IPNS record
Variables ¶
Functions ¶
func AddDirectory ¶
Resursively add a directory to IPFS and return the root hash
func CreatePointerKey ¶ added in v0.6.3
func FetchGraph ¶ added in v0.9.2
func FetchGraph(dag merkledag.DAGService, id *cid.Cid) ([]cid.Cid, error)
This function takes a Cid directory object and walks it returning each linked cid in the graph
func FindPointers ¶
func FindPointers(ctx context.Context, dht *routing.IpfsDHT, mhKey multihash.Multihash, prefixLen int) ([]ps.PeerInfo, error)
FindPointers fetches pointers from the dht
func FindPointersAsync ¶
func FindPointersAsync(ctx context.Context, dht *routing.IpfsDHT, mhKey multihash.Multihash, prefixLen int) <-chan ps.PeerInfo
FindPointersAsync fetches pointers from the dht. They will be returned asynchronously.
func GetHashOfFile ¶ added in v0.5.5
func GetPointersFromPeer ¶ added in v0.9.3
func GetPointersFromPeer(node *core.IpfsNode, ctx context.Context, p peer.ID, key *cid.Cid) ([]*ps.PeerInfo, error)
GetPointersFromPeer sends a message to request dht pointers from a peer
func IdentityFromKey ¶
IdentityFromKey returns IPFS peer identity based on private key
func IdentityKeyFromSeed ¶
IdentityKeyFromSeed generates an OpenBazaar seed IPFS key pair
func MockCmdsCtx ¶
func MockHostOption ¶
func MockHostOption(mn mocknet.Mocknet) core.HostOption
func NewMockNode ¶
NewMockNode constructs an IpfsNode for use in tests.
func NewRequest ¶
func NewRequestWithTimeout ¶ added in v0.1.1
func PublishPointer ¶
PublishPointer adds and publishes pointer to the dht.
func PutPointerToPeer ¶ added in v0.9.3
func PutPointerToPeer(node *core.IpfsNode, ctx context.Context, peer peer.ID, pointer Pointer) error
PutPointerToPeer routes a dht pointer to a peer
func ResolveThenCat ¶ added in v0.1.1
Types ¶
type Pointer ¶
type Pointer struct { Cid *cid.Cid Value ps.PeerInfo Purpose Purpose Timestamp time.Time CancelID *peer.ID }
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 NewPointer ¶ added in v0.9.2
func NewPointer(mhKey multihash.Multihash, prefixLen int, addr ma.Multiaddr, entropy []byte) (Pointer, error)
NewPointer creates a new pointer. 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