richardschneider / net-ipfs-http-client

InterPlanetary File System client for .Net (C#, VB, F# ...)
MIT License
158 stars 52 forks source link

Implement DAG API #30

Closed richardschneider closed 6 years ago

richardschneider commented 6 years ago

From email disucussions with @mjeronimoa

from @mjeronimoa First of all, thanks for your great contribution to the open source environment. I'have just started to use your ipfs c# library and it has been working great till now in my Xamarin app. I have reached a point where I would like to use the dag API, but as you explain in the documentation, it is not implemented yet. I would like to know if there is any beta implementation or first steps, and if not, I would like to cooperate and try help with the development, so any advise would be welcome. (I'm not asking you to implement it for me, just that I don't want to do any rework in case you already have implemented anything)

from @richardschneider Great to hear that it works with Xamarin, never tested against it.

No work has been done on the DAG API. Please feel free to start working on it. I suggest that you start with net-ipfs-core and define the interface. Take a look at https://ipfs.io/docs/api/#api-v0-dag-get and https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md

DAG API is considered to be a replacement for the OBJECT API. Maybe you can use it! Tell me what you are trying to do.

I'm at UTC+12, so replies may take a few hours.

from @mjeronimoa Thanks for your "quick" response (I think we could not be farther one from each other).

I have taken a look at the links you sent me and they have been really useful. I have already started to write some code to get familiar with the one in your github. For the moment I have been able to run the command with a cid and get a JSON response, that I have deserialized into a new class object I just created.

While doing this, a couple of questions came to my mind, and maybe you can give some hints: -According to the official documentation, dag/get should return a Dag Node, but checking the current code I have seen that class already exist in the Object API. Any recommendation about how to name the new class? what about something like "IPLDNode" (I'm really new with IPFS and I'm afraid I'm still don't understand some of the concepts). -While doing some test, I have seen that you can get two completely different results from the dag/get command, depending if you are in the root of the cid (info regarding the branches) or inside one of the branches (author, committer, message...). Any idea of how to solve this?

I will continue working on this, and as soon as I have something stable I would like to commit it to the fork I just created on my github, so you can then take a look into it. I would like to spend more time on this, but I still have to work on other topics at the same time, but meanwhile, I would like to keep you updated on my progress.

richardschneider commented 6 years ago

According to the official documentation, dag/get should return a Dag Node, but checking the current code I have seen that class already exist in the Object API. Any recommendation about how to name the new class? what about something like "IPLDNode" (I'm really new with IPFS and I'm afraid I'm still don't understand some of the concepts).

I agree that dag.get should return a IPLDNode; which is not defined. According to the spec, IPLD is a JSON-based data model for representing merkle-dags. The JObject can be used for this.

Perhaps the signatures should be

Task<JObject> GetAsync(string path, CancellationToken cancel = default(CancellationToken));
Task<Cid> PutAsync(
   JObject data,
   string contentType,
   string multiHash = MultiHash.DefaultAlgorithmName,
   CancellationToken cancel = default(CancellationToken));
richardschneider commented 6 years ago

While doing some test, I have seen that you can get two completely different results from the dag/get command, depending if you are in the root of the cid (info regarding the branches) or inside one of the branches (author, committer, message...). Any idea of how to solve this?

Can you show the test and results or just point me to test repo/fork?

Some good tests, in JS, can be found at https://github.com/ipfs/js-ipfs/tree/master/examples/traverse-ipld-graphs

richardschneider commented 6 years ago

@mjeronimoa I've released v0.20.0 that implements DAG API. Hope you like it.

Please feel free to raise any issues.