Documentation ¶
Index ¶
- Constants
- Variables
- 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 DeleteCachedIPNSRecord(store ds.Datastore, id peer.ID) error
- 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 GetCachedIPNSRecord(store ds.Datastore, id peer.ID) (*ipnspb.IpnsEntry, error)
- func GetCachedPubkey(store ds.Datastore, peerID string) ([]byte, error)
- func GetHash(n *core.IpfsNode, reader io.Reader) (string, error)
- func GetHashOfFile(n *core.IpfsNode, fpath string) (string, error)
- func GetPointersFromPeer(dht *routing.IpfsDHT, 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 InstallDatabasePlugins()
- func PrepareIPFSConfig(r repo.Repo, routerAPIEndpoint string, testEnable, regtestEnable bool) *ipfscore.BuildCfg
- func Publish(n *core.IpfsNode, hash string) error
- func PublishPointer(dht *routing.IpfsDHT, ctx context.Context, pointer Pointer) error
- func PutCachedPubkey(store ds.Datastore, peerID string, pubkey []byte) error
- func PutPointerToPeer(dht *routing.IpfsDHT, ctx context.Context, peer peer.ID, pointer Pointer) error
- func Query(dht *routing.IpfsDHT, peerID string) ([]peer.ID, error)
- func RemoveAll(nd *core.IpfsNode, peerID string, quorum uint) error
- func Resolve(n *core.IpfsNode, p peer.ID, timeout time.Duration, quorum uint, 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 ipath.Path, timeout time.Duration, quorum uint, ...) ([]byte, error)
- func UnPinDir(n *core.IpfsNode, rootHash string) error
- func UpdateIPFSGlobalProtocolVars(testnetEnable bool)
- type APIRouter
- func (r APIRouter) Bootstrap(_ context.Context) error
- func (r APIRouter) FindPeer(_ context.Context, id peer.ID) (pstore.PeerInfo, error)
- func (r APIRouter) FindProvidersAsync(_ context.Context, _ cid.Cid, _ int) <-chan pstore.PeerInfo
- func (r APIRouter) GetValue(ctx context.Context, key string, opts ...ropts.Option) ([]byte, error)
- func (r APIRouter) GetValues(ctx context.Context, key string, opts ...ropts.Option) ([]byte, error)
- func (r APIRouter) Provide(_ context.Context, _ cid.Cid, _ bool) error
- func (r APIRouter) PutValue(ctx context.Context, key string, value []byte, opts ...ropts.Option) error
- func (r APIRouter) SearchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error)
- func (r *APIRouter) Start(proxyDialer proxy.Dialer)
- type CachingRouter
- func (r *CachingRouter) APIRouter() *APIRouter
- func (r *CachingRouter) DHT() (*dht.IpfsDHT, error)
- func (r *CachingRouter) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error)
- func (r *CachingRouter) GetValue(ctx context.Context, key string, opts ...ropts.Option) ([]byte, error)
- func (r *CachingRouter) PutValue(ctx context.Context, key string, value []byte, opts ...ropts.Option) error
- func (r *CachingRouter) SearchValue(ctx context.Context, key string, opts ...ropts.Option) (<-chan []byte, error)
- type Pointer
- type Pubsub
- type PubsubPublisher
- type PubsubSubscriber
- type Purpose
Constants ¶
const ( IPFSProtocolAppMainnetOne = "/openbazaar/app/1.0.0" IPFSProtocolAppTestnetOne = "/openbazaar/app/testnet/1.0.0" IPFSProtocolBitswapMainnetNoVers = "/openbazaar/bitswap" IPFSProtocolBitswapMainnetOne = "/openbazaar/bitswap/1.0.0" IPFSProtocolBitswapMainnetOneDotOne = "/openbazaar/bitswap/1.1.0" IPFSProtocolBitswapTestnetNoVers = "/openbazaar/bitswap/testnet" IPFSProtocolBitswapTestnetOne = "/openbazaar/bitswap/testnet/1.0.0" IPFSProtocolBitswapTestnetOneDotOne = "/openbazaar/bitswap/testnet/1.1.0" IPFSProtocolDHTMainnetLegacy = "/openbazaar/dht" IPFSProtocolDHTTestnetLegacy = "/openbazaar/dht/testnet" IPFSProtocolKademliaMainnetOne = "/openbazaar/kad/1.0.0" IPFSProtocolKademliaTestnetOne = "/openbazaar/kad/testnet/1.0.0" )
const MagicPointerID string = "000000000000000000000000"
Variables ¶
var (
ErrCachingRouterIncorrectRoutingType = errors.New("Incorrect routing type")
)
var ErrNotStarted = errors.New("API router not started")
ErrNotStarted is returned if a method is called before the router is started using the Start() method.
Functions ¶
func AddDirectory ¶
Recursively add a directory to IPFS and return the root hash
func ConnectedPeers ¶
func CreatePointerKey ¶ added in v0.6.3
func CreatePointerKey(mh multihash.Multihash, prefixLen int) multihash.Multihash
func DeleteCachedIPNSRecord ¶ added in v0.13.6
DeleteCachedIPNSRecord removes the cached record associated with the provided peer.ID
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)
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 GetCachedIPNSRecord ¶ added in v0.13.6
GetCachedIPNSRecord retrieves the full IPNSEntry from the provided datastore if present
func GetCachedPubkey ¶ added in v0.13.6
GetCachedPubkey retrieves the pubkey using the appropriate key prefix from the provided Datastore
func GetHashOfFile ¶ added in v0.5.5
func GetPointersFromPeer ¶ added in v0.9.3
func IdentityFromKey ¶
func InstallDatabasePlugins ¶ added in v0.13.3
func InstallDatabasePlugins()
InstallDatabasePlugins installs the default database plugins used by openbazaar-go. This function is guarded by a sync.Once so it isn't accidentally called more than once.
func PrepareIPFSConfig ¶ added in v0.13.3
func PrepareIPFSConfig(r repo.Repo, routerAPIEndpoint string, testEnable, regtestEnable bool) *ipfscore.BuildCfg
PrepareIPFSConfig builds the configuration options for the internal IPFS node.
func PublishPointer ¶
func PutCachedPubkey ¶ added in v0.13.6
PutCachedPubkey persists the pubkey using the appropriate key prefix from the provided datastore
func PutPointerToPeer ¶ added in v0.9.3
func Resolve ¶ added in v0.1.1
func Resolve(n *core.IpfsNode, p peer.ID, timeout time.Duration, quorum uint, usecache bool) (string, error)
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
func UnPinDir ¶
Recursively un-pin a directory given its hash.
This will allow it to be garbage collected.
func UpdateIPFSGlobalProtocolVars ¶ added in v0.13.3
func UpdateIPFSGlobalProtocolVars(testnetEnable bool)
UpdateIPFSGlobalProtocolVars is a hack to manage custom protocol strings which do not yet have an API to manage their configuration
Types ¶
type APIRouter ¶ added in v0.13.3
type APIRouter struct {
// contains filtered or unexported fields
}
APIRouter is a routing.IpfsRouting compliant struct backed by an API. It only provides the features offerened by routing.ValueStore and marks the others as unsupported.
func NewAPIRouter ¶ added in v0.13.3
NewAPIRouter creates a new APIRouter backed by the given URI.
func (APIRouter) Bootstrap ¶ added in v0.13.3
Bootstrap is a no-op. We don't need any setup to query the API.
func (APIRouter) FindProvidersAsync ¶ added in v0.13.3
FindProvidersAsync is unsupported
func (APIRouter) GetValues ¶ added in v0.13.3
GetValues reads the value for the given key. The API does not return multiple values.
func (APIRouter) PutValue ¶ added in v0.13.3
func (r APIRouter) PutValue(ctx context.Context, key string, value []byte, opts ...ropts.Option) error
PutValue writes the given value to the API for the given key
type CachingRouter ¶ added in v0.13.3
type CachingRouter struct { routing.IpfsRouting // contains filtered or unexported fields }
func NewCachingRouter ¶ added in v0.13.3
func NewCachingRouter(dht *dht.IpfsDHT, apiRouter *APIRouter) *CachingRouter
func (*CachingRouter) APIRouter ¶ added in v0.13.3
func (r *CachingRouter) APIRouter() *APIRouter
func (*CachingRouter) DHT ¶ added in v0.13.3
func (r *CachingRouter) DHT() (*dht.IpfsDHT, error)
func (*CachingRouter) GetPublicKey ¶ added in v0.13.3
func (*CachingRouter) SearchValue ¶ added in v0.13.3
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 NewPointer ¶ added in v0.9.2
func NewPointer(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 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 *pubsub.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 *pubsub.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