Tools for working with Filecoin types in go-ipld-prime #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals
Recently, go-ipld-prime has received a number of enhancements that make it much easier to work directly with go types as IPLD nodes in the form of the
bindnode
package.bindnode
wraps go types as IPLD nodes usingreflect
and IPLD schemas.bindnode
also provides hooks that allow you to use custom data types in go structs you wrap as IPLD nodes. The PR provides default hooks for a few data types we've already encountered as we worked to convert go-data-transfer v2 to using pure go-ipld-prime and use it with go-fil-markets and boost. While we currently have these hooks embedded in the fil-markets and boost code (duplicated), they are useful to consumers beyond fil-markets -- namely anyone who wants to work with Filecoin types using go-ipld-prime -- either as an alternative to cbor-gen for serialization or to run selectors on Filecoin state (as possible useful example).Implementation
bindnode hooks for:
test to prove out roundtrip serialization with a sample type