-
Notifications
You must be signed in to change notification settings - Fork 25
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
make hamt a go-ipld-prime ipld.Node #70
base: master
Are you sure you want to change the base?
Conversation
Thanks for showing what this would look like. My first reaction here is that it's a lot of noise with little immediate value to the core use case of actors. Since the Filecoin actors code is so security-critical, and with very strict compatibility requirements, our general desire is to minimize any unnecessary code and dependencies. I didn't see a This HAMT is, unfortunately, not built with I infer that you wanted this compatibility for some downstream processing. Would it work to locally extend the HAMT struct, instead of modifying it here? |
This does not need to depend on |
longer term, i'll transition that to the in-progress ipld-schema'd hamt, but this works as a branch for ipld tools to use in the short term. I don't think it needs to be merged, but it's useful for me to maintain it as a branch on this repo so that i can pull in the v3 changes as they finalize. |
@@ -6,11 +6,10 @@ require ( | |||
github.com/ipfs/go-cid v0.0.6 | |||
github.com/ipfs/go-ipld-cbor v0.0.4 | |||
github.com/ipfs/go-ipld-format v0.0.2 // indirect | |||
github.com/kr/pretty v0.1.0 // indirect | |||
github.com/ipld/go-ipld-prime v0.12.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you staying on an older go-ipld-prime on purpose?
} | ||
|
||
func loadPointer(p ipld.Node) (*Pointer, error) { | ||
if p.Kind() != ipld.Kind_Link { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you could use a switch here
|
||
func loadKV(n ipld.Node) (*KV, error) { | ||
if n.Kind() != ipld.Kind_List { | ||
return nil, fmt.Errorf("kv should be of kind list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: include the actual kind
} | ||
return &Pointer{KVs: kvs}, nil | ||
} | ||
return nil, fmt.Errorf("unsupported pointer kind") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto with including the actual kind
return nil, e | ||
} | ||
return n.LookupByString(s) | ||
} else if key.Kind() == ipld.Kind_Bytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto switch and actual kind in the error
} | ||
|
||
func (n *Node) IsNull() bool { | ||
return n.Bitfield == nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that "is null" should only ever return true if the node is nullable, e.g. a nullable struct field, which I imagine is not the case here. It's not a generic "is empty/zero" that can be useful for any node.
|
||
// LSBlockstore creates a blockstore (get/put) interface over a link system | ||
type LSBlockstore struct { | ||
*ipld.LinkSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: embedding this means you're also exposing its methods on your API, so perhaps you want to make it a named and unexported field instead
2022-04-05 conversation: the potential areas of concern that we need in review:
|
This is a complementary code path and will not affect any current use cases. |
@willscott: 2022-04-19 conversation notes:
This is a good change, but it does increase the amount that someone needs to understand to properly maintain this library. |
ipld.NodePrototype
is a bit janky. Would be interested in suggestions on how to make that cleaner.NodeBuilder
/NodeAssembler
, so won't automatically load.context.Background
is used. Ideally, a context on the node would allow for graceful cancellation of in-progress operations.