Closed eduardonunesp closed 3 years ago
I'm moving to connect HAMT's structures using ipld.Link
with assembler.AssembleValue().AssignLink
. But would be awesome if the AssignLink
already does that heavy lifting, kind of would be easier to connect sub HAMTs
AssignLink takes a link, so it can't possibly do anything smarter :) Note that I think AssignLink for map entry values is a TODO, but we can fix that fairly easily.
Ops, looks like there's an error when try to put ipld.Link
as value for a HAMT
, I created an example that can be found at https://gist.github.com/eduardonunesp/367df320957e75ef43f1002a68cbec49, the example just puts the ipld
and hamt
stuff and put inside a container
to create a common procedure to create new hamt
easier.
Error is
panic: func called on wrong kind: AssignLink called on a bytes node (kind: bytes), but only makes sense on link
goroutine 1 [running]:
main.errCheck(...)
/Users/eduardo/Sandbox/go-hamt-test/utils.go:5
main.main()
/Users/eduardo/Sandbox/go-hamt-test/main.go:136 +0x3dc
Yep that's the TODO I mentioned earlier, I'll send a fix tomorrow.
Thanks @mvdan for the fixes 👍🏼
What is the properly way to link sub HAMT structures, let's say the structure needs to be nested like the following idea (based in the following json, let's pretend that each object is a bucket)
The following code tries to create a main HAMT and nested HAMT but it failed with an error:
The example above would produce something like: