README.md 1.33 KB
Newer Older
Rod Vagg's avatar
Rod Vagg committed
1 2
# go-dagpb

3
**An implementation of the IPLD [DAG-PB](https://gitlab.dms3.io/ld/specs/blob/master/block-layer/codecs/dag-pb.md) spec for [go-ld-prime](https://gitlab.dms3.io/ld/go-ld-prime/)**
Rod Vagg's avatar
Rod Vagg committed
4

5
Use `Decode(ld.NodeAssembler, io.Reader)` and `Encode(ld.Node, io.Writer)` directly, or import this package to have this codec registered into the go-ld-prime CID link loader.
Rod Vagg's avatar
Rod Vagg committed
6 7 8

Nodes encoded with this codec _must_ conform to the DAG-PB spec. Specifically, they should have the non-optional fields shown in the DAG-PB schema:

9
```ldsch
Rod Vagg's avatar
Rod Vagg committed
10 11 12 13 14 15 16 17 18 19 20 21
type PBNode struct {
  Links [PBLink]
  Data optional Bytes
}

type PBLink struct {
  Hash Link
  Name optional String
  Tsize optional Int
}
```

22
Use `dagpb.Type.PBNode` and friends directly for strictness guarantees. Basic `ld.Node`s will need to have the appropraite fields (and no others) to successfully encode using this codec.
Rod Vagg's avatar
Rod Vagg committed
23 24 25 26 27 28 29 30 31 32 33 34 35

## License & Copyright

Copyright © 2020 Protocol Labs

Licensed under either of

 * Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
 * MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.