Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Making resolve and IPLD service into a new package #58

Closed
2 tasks
nicola opened this issue Sep 12, 2016 · 6 comments
Closed
2 tasks

Making resolve and IPLD service into a new package #58

nicola opened this issue Sep 12, 2016 · 6 comments

Comments

@nicola
Copy link
Member

nicola commented Sep 12, 2016

I am now writing some very demo code to show IPLD.

I run into the following: js-ipld does not resolve a path query, so for example, given an object (that I have in memory), I can't use merkle paths to point to any attribute.

  1. It would be great to have a function that resolves a path given a service (resolve(service, path))
  2. It would be great if we make an IPLD service that is dum - basically just a memory store, there is no need to run the entire IPFS
@daviddias
Copy link
Member

daviddias commented Sep 12, 2016

The IPLD Service uses the BlockStore and BlockStore can use any blob-store implementation (fs, memory, indexedDB, etc)

👍 for having the resolver as a separate package. In fact, I just suggested that for the MerkleDAG as well minutes ago:) ipfs/js-ipfs#478 (comment)

@daviddias
Copy link
Member

From the chat in IRC, @nicola is looking to have an IPLD sandbox so that it is easy to attach an in memory IPLD service, without having to do the 'IPFS Repo -> IPFS Block Service -> IPFS Dag Service' dance.

@dignifiedquire
Copy link
Member

The current interactions with the ipfs-repo are pretty minimal at this point, so we can abstract things out.

We only use the blockservice, and from that we need three methods

  • getStream(key)
  • putStream(cb)
  • delete(key, cb)

So we would move the majority of this code into something called js-ipld-service and this repo would look like this

class IpfsIpldService extends IPLDService {
  constructor (blockservice) {
    super({
      getStream (key) {
        return blockservice.getStream(key, 'ipld')
      },

      putStream (cb) {
        return pull(
          pull.map((node) => new Block(node, 'ipld')),
          blockservice.putStream(),
          pull.onEnd(cb)
        )
      },

      delete (key, cb) {
        return blockservice.delete(key, cb)
      }
    })
  } 
}

@nicola
Copy link
Member Author

nicola commented Sep 12, 2016

This is the modularity I was looking for :)
And maybe taking out resolve!

@daviddias
Copy link
Member

@nicola let's chat during today's js-ipfs chat, you will like what is happening on #60 :) (also, I really want your input on it, getting super close)

@daviddias
Copy link
Member

This issue is no longer applicable. In fact the new version has what you were looking for, @nicola :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants