Documentation ¶
Index ¶
- Constants
- func AddDirectory(n *core.IpfsNode, root string) (rootHash string, err error)
- func AddFile(n *core.IpfsNode, file string) (string, error)
- func Cat(n *core.IpfsNode, path string, timeout time.Duration) ([]byte, error)
- func ConnectedPeers(n *core.IpfsNode) []peer.ID
- func CreatePointerKey(mh multihash.Multihash, prefixLen int) multihash.Multihash
- func FetchGraph(n *core.IpfsNode, id *cid.Cid) ([]cid.Cid, error)
- func FindPointers(dht *routing.IpfsDHT, ctx context.Context, mhKey multihash.Multihash, ...) ([]ps.PeerInfo, error)
- func FindPointersAsync(dht *routing.IpfsDHT, ctx context.Context, mhKey multihash.Multihash, ...) <-chan ps.PeerInfo
- func GetHash(n *core.IpfsNode, reader io.Reader) (string, error)
- func GetHashOfFile(n *core.IpfsNode, 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 Publish(n *core.IpfsNode, hash string) error
- func PublishAltRoot(nd *core.IpfsNode, altRoot string, value path.Path, eol time.Time) error
- func PublishPointer(node *core.IpfsNode, ctx context.Context, pointer Pointer) error
- func PutPointerToPeer(node *core.IpfsNode, ctx context.Context, peer peer.ID, pointer Pointer) error
- func PutRecordToRouting(ctx context.Context, ipnskey string, k ci.PrivKey, value path.Path, ...) error
- func Query(n *core.IpfsNode, peerID string) ([]peer.ID, error)
- func RemoveAll(nd *core.IpfsNode, peerID string) error
- func Resolve(n *core.IpfsNode, p peer.ID, timeout time.Duration, usecache bool) (string, error)
- func ResolveAltRoot(n *core.IpfsNode, p peer.ID, altRoot string, timeout time.Duration) (string, error)
- func ResolveThenCat(n *core.IpfsNode, ipnsPath path.Path, timeout time.Duration, usecache bool) ([]byte, error)
- func UnPinDir(n *core.IpfsNode, rootHash string) error
- type Pointer
- type Pubsub
- type PubsubPublisher
- type PubsubSubscriber
- type Purpose
Constants ¶
const ( MessageTopicPrefix = "/offlinemessage/" GlobalIPNSTopic = "IPNS" GlobalBlockTopic = "BLOCK" GlobalCIDTopic = "CID" )
const MAGIC string = "000000000000000000000000"
MAGIC is a constant combined with a hashed key when creating a magic ID.
Variables ¶
This section is empty.
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
This function takes a Cid directory object and walks it returning each linked cid in the graph
func FindPointers ¶
func FindPointers(dht *routing.IpfsDHT, ctx context.Context, mhKey multihash.Multihash, prefixLen int) ([]ps.PeerInfo, error)
FindPointers fetches pointers from the dht
func FindPointersAsync ¶
func FindPointersAsync(dht *routing.IpfsDHT, ctx context.Context, 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 PublishAltRoot ¶ added in v0.12.0
Publish another IPFS record at /ipns/<peerID>:<altRoot>
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 PutRecordToRouting ¶ added in v0.12.0
func Resolve ¶ added in v0.1.1
Resolve an IPNS record. This is a multi-step process. If the usecache flag is provided we will attempt to load the record from the database. If it succeeds we will update the cache in a separate goroutine.
If we need to actually get a record from the network the IPNS namesystem will first check to see if it is subscribed to the name with pubsub. If so, it will return cache from the database. If not, it will subscribe to the name and proceed to a DHT query to find the record. If the DHT query returns nothing it will finally attempt to return from cache. All subsequent resolves will return from cache as the pubsub will update the cache in real time as new records are published.
func ResolveAltRoot ¶ added in v0.12.0
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
type Pubsub ¶ added in v0.12.4
type Pubsub struct { Subscriber *PubsubSubscriber Publisher *PubsubPublisher }
type PubsubPublisher ¶ added in v0.12.4
type PubsubPublisher struct {
// contains filtered or unexported fields
}
PubsubPublisher is a publisher that distributes arbitrary data through pubsub
func NewPubsubPublisher ¶ added in v0.12.4
func NewPubsubPublisher(ctx context.Context, host p2phost.Host, cr routing.ContentRouting, ds ds.Datastore, ps *floodsub.PubSub) *PubsubPublisher
NewPubsubPublisher constructs a new Publisher that publishes arbitrary data through pubsub.
type PubsubSubscriber ¶ added in v0.12.4
type PubsubSubscriber struct {
// contains filtered or unexported fields
}
PubsubSubscriber subscribes to arbitrary subscriptions through pubsub
func NewPubsubSubscriber ¶ added in v0.12.4
func NewPubsubSubscriber(ctx context.Context, host p2phost.Host, cr routing.ContentRouting, ds ds.Datastore, ps *floodsub.PubSub) *PubsubSubscriber
NewPubsubSubscriber constructs a new subscriber for arbitrary subscriptions through pubsub. same as above for pubsub bootstrap dependencies
func (*PubsubSubscriber) Cancel ¶ added in v0.12.4
func (r *PubsubSubscriber) Cancel(name string) bool
Cancel cancels a topic subscription; returns true if an active subscription was canceled
func (*PubsubSubscriber) GetSubscriptions ¶ added in v0.12.4
func (r *PubsubSubscriber) GetSubscriptions() []string
GetSubscriptions retrieves a list of active topic subscriptions