ipfs / go-ipfs-api

The go interface to ipfs's HTTP API
MIT License
456 stars 178 forks source link

How to get local node instance from shell? #264

Closed mar1n3r0 closed 2 years ago

mar1n3r0 commented 2 years ago

Scenario:

We have a running local daemon. A client wasm app in the browser requires an orbit-db connection. To create new OrbitDB instance we need coreapi.CoreAPI param.

// NewOrbitDB Creates a new OrbitDB instance with default access controllers and store types
func NewOrbitDB(ctx context.Context, i coreapi.CoreAPI, options *NewOrbitDBOptions) (iface.OrbitDB, error) {

We can not create a new node because ipfs can not use wasm target.

node, err := core.NewNode(ctx, nodeOptions)
if err != nil {
       return nil, err
}

// Attach the Core API to the constructed node
return coreapi.NewCoreAPI(node)

We can create a new shell though:

// Where your local node is running on localhost:5001
sh := shell.NewShell("localhost:5001")

There is a method to get the peer id: sh.ID()

Is it possible to get *core.ipfsNode instance from the shell?

welcome[bot] commented 2 years ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

aschmahmann commented 2 years ago

Support questions are best asked on discuss.ipfs.io as mentioned above and if you have further questions feel free to ask there or on one of the community chat channels. In any event you're likely looking for https://github.com/ipfs/go-ipfs-http-client.