Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First version (reworked) #16

Merged
merged 80 commits into from
Jan 21, 2020
Merged

First version (reworked) #16

merged 80 commits into from
Jan 21, 2020

Conversation

aeddi
Copy link
Member

@aeddi aeddi commented Dec 1, 2019

Hello everyone, :)

Here is the first version of the packages reworked according to the plan established in #14.

Both Android and iOS packages work almost the same way: we have written an IPFS class that wrap the underlying golang objects at the initialization of which we can configure the repo path.
Then we implemented some methods that allow users to start/stop the node and send command to the API:

import  ipfs.gomobile.android.IPFS;

IPFS ipfs = new IPFS(getApplicationContext());
ipfs.start();
byte[] data = ipfs.command("/cat?arg=" + CID);

By default, the API is configured to only be accessible through UDS (faster and safer). BTW we lowered the minimum RSA key length to 1024 to be able to connect to the bootstrap nodes. More info here.

We have kept things simple in order to implement and maintain as little code as possible, knowing that some things may change. We also implemented helpers for commands (toDict on iOS and toJSON on Android) but we have chosen to leave the configuration of the node accessible only by making request to the API (or using golang object directly).

We have written sample applications for both platforms that display the peer ID, the number of peers connected and allows you to fetch a random XKCD on IPFS then to display it.

We would like a review from a member of the Textile or Protocol labs team before merging on master if possible. :)
Then we think it might cool to make the repo open source so that people can start playing with it (we first need to update the README which is no longer relevant).

gfanton and others added 30 commits December 1, 2019 20:53
* Split pkg into repo/host/node
  * host build mobile dedicated host (noop for the moment)
  * repo build mobile dedicated repo, exactly the same as ipfs repo but add the
    ability to add some custom configuration
  * node build mobile dedicated node with the particularity to create a mobile host
* the main package can be bind using gomobile to create a ready-to-use
  framework/aar
* individual pkg can be imported instead and be used for specific project
* Add simple makefile that show how to build the thing
@aeddi
Copy link
Member Author

aeddi commented Jan 20, 2020

Hello @Stebalien,

We have implemented the required changes in the last few commits.

To retrieve XKCD cIDs from IPNS we had to find a workaround to resolve DNS from go on Android. We based it on this gist: https://gist.github.com/cs8425/107e01a0652f1f1f6e033b5b68364b5e

About passing stream as argument / returning stream for the "command" methods, I will a open PR this week. I've already finished the code on Android, I just need to finish it on iOS.

Do the latest changes look good to you?

Gist
DNS resolve workaround for android in pure go. GitHub Gist: instantly share code, notes, and snippets.

Same as Android, ipns fail to resolve dns on iOS.
Use the same fix than Android
@gfanton
Copy link
Member

gfanton commented Jan 20, 2020

To retrieve XKCD cIDs from IPNS we had to find a workaround to resolve DNS from go on Android. We based it on this gist: https://gist.github.com/cs8425/107e01a0652f1f1f6e033b5b68364b5e

We just notice that we have the same problem on iOS physical device (and not in iOS simulator), for the moment we will use this fix for the moment, but we will try to implement github.com/ipfs/go-ipfs/namesys.NameSystem and use Native Android/iOS DNS resolver as a cleaner approach until this golang issue is fix

Gist
DNS resolve workaround for android in pure go. GitHub Gist: instantly share code, notes, and snippets.

@gfanton gfanton requested a review from Stebalien January 20, 2020 23:38
README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,75 @@
// from: https://gist.github.com/cs8425/107e01a0652f1f1f6e033b5b68364b5e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

Well, I guess if that's all we can do...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's very hacky :/
We already know how to solve the problem in a cleaner way, we're going to create issues with all the things that need to be done.

}

datastore := defaultDatastoreConfig()
conf := &ipfs_config.Config{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection manager only runs once a minute. Are you seeing a sawtooth pattern? and how many connections are you seeing?

return nil, err
}

ma.ForEach(a, func(c ma.Component) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've cut a v0.0.3 release with your changes. You should be able to drop this code.

}
}

func (s *Shell) Request(uri string, body []byte) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need this function?

}
}

func (s *Shell) Request(uri string, body []byte) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nothing particularly wrong with it, just awkward to go from a request to a url to a request and then back to the url)

@Stebalien
Copy link
Contributor

We just notice that we have the same problem on iOS physical device (and not in iOS simulator), for the moment we will use this fix for the moment, but we will try to implement github.com/ipfs/go-ipfs/namesys.NameSystem and use Native Android/iOS DNS resolver as a cleaner approach until this golang issue is fix

Ideally, you'd be able to override the DNS resolver when constructing IPFS.

@ghost
Copy link

ghost commented Jan 21, 2020

There were the following issues with this Pull Request

  • Commit: 32df912
    • ✖ message may not be empty
    • ✖ type may not be empty

You may need to change the commit messages to comply with the repository contributing guidelines.


🤖 This comment was generated by commitlint[bot]. Please report issues here.

Happy coding!

aeddi and others added 2 commits January 21, 2020 14:24
Co-Authored-By: Steven Allen <steven@stebalien.com>
@ipfs-shipyard ipfs-shipyard deleted a comment Jan 21, 2020
@aeddi
Copy link
Member Author

aeddi commented Jan 21, 2020

Fixes #14, #2 and #1

We have opened a number of issues related to points discussed in this PR:

I will opened several issues about request in/out streams, lifecycle management, etc...

@aeddi aeddi merged commit 97dc855 into ipfs-shipyard:master Jan 21, 2020
@aeddi aeddi deleted the dev/init-repo branch January 21, 2020 17:44
@github-actions
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@moul moul added this to the 1. Initial Milestone milestone Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants