ipfs / go-ipld-format

IPLD Node and Resolver interfaces in Go
https://github.com/ipld/ipld
MIT License
64 stars 26 forks source link

API Todos #5

Open whyrusleeping opened 7 years ago

whyrusleeping commented 7 years ago
whyrusleeping commented 7 years ago

Also make Link an interface

ghost commented 7 years ago

Let's do this now while we're making Link part of the coreapi?

Stebalien commented 7 years ago
  1. Don't use Links, those have name/size fields and are IPFS specific.
  2. Remove the Copy() method. Generic nodes are supposed to be immutable so it only really makes sense to copy them once they've been downcast to a concrete node type.
  3. Move Stat() to an IPFSNode type (not in this package).
  4. Either move Size() to Block or remove it. It currently means two different things in different places (`ProtoNode.Size() computes the size of the dag, current node + linked nodes).
  5. Whatever we do with Size(), it shouldn't be able to return an error (given that one can compute it with uint64(len(node.RawData())).
Stebalien commented 7 years ago

I've moved these into their own issues.

  1. 9

  2. 10

  3. 11

  4. 12

  5. 12

Stebalien commented 7 years ago

Move dagservice interface definition here

8

Standardize errors from implementation packages into here (ErrNoSuchLink, ErrNotLink, etc)

13

Remove ResolveLink method from interface. Add helper function to this package instead

Having a ResolveLink method on the interface could be useful optimizing link traversal. However, a better way to do this would be specialization (or whatever go calls it): Define the helper function, define a NodeWithResolveLink interface, and then try to cast to NodeWithResolveLink in the helper function. This way, implementers can optimize multi-hop link resolution by implementing this interface but they don't need to.

Also make Link an interface

Or just use CIDs (#9)?


For context, I'm trying break this issue into actionable smaller issues and close it.

ghost commented 7 years ago

Need some orientation. What are the use cases for ResolveLink?