/
unmarshal.go
25 lines (20 loc) · 935 Bytes
/
unmarshal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package validator_tree
import (
"io"
"github.com/ipld/go-ipld-prime"
mt "github.com/vulcanize/go-codec-dagcosmos/merkle_tree"
)
// Decode provides an IPLD codec decode interface for Tendermint ValidatorTree IPLDs.
// This function is registered via the go-ipld-prime link loader for multicodec
// code XXX when this package is invoked via init.
// This simply wraps mt.DecodeTrieNode with the proper multicodec type
func Decode(na ipld.NodeAssembler, in io.Reader) error {
return mt.DecodeTrieNode(na, in, MultiCodecType)
}
// DecodeBytes is like Decode, but it uses an input buffer directly.
// Decode will grab or read all the bytes from an io.Reader anyway, so this can
// save having to copy the bytes or create a bytes.Buffer.
// This simply wraps mt.DecodeTrieNodeBytes with the proper multicodec type
func DecodeBytes(na ipld.NodeAssembler, src []byte) error {
return mt.DecodeTrieNodeBytes(na, src, MultiCodecType)
}