ipld/interface-ipld-format

Name: interface-ipld-format

Owner: IPLD

Description: A interface you can follow to implement a valid IPLD format, resolvable through the IPLD Resolver (available in IPFS)

Created: 2016-10-02 19:49:28.0

Updated: 2018-05-20 06:41:02.0

Pushed: 2018-05-10 09:59:53.0

Homepage: null

Size: 63

Language: null

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

interface-ipld-format

standard-readme compliant

A interface you can follow to implement a valid IPLD format, resolvable through the IPLD Resolver (available in IPFS)

Table of Contents
Background

The primary goal of this module is to define an interface that IPLD formats can implement and attach to any IPLD Resolver. The API is presented with both Node.js and Go primitives. However, there are no actual limitations keeping it from being extended for any other language, pushing forward cross compatibility and interoperability through different stacks.

Modules that implement the interface

Send in a PR if you find or write one!

Badge

Include this badge in your readme if you make a new module that implements interface-ipld-format API.

Definitions
API

A valid (read: that follows this interface) IPLD format implementation the following API.

IPLD format utils
util.serialize(dagNode, callback)

serializes a dagNode of an IPLD format into its binary format

callback must have the signature function (err, binaryBlob), where err is an Error is the function fails and binaryBlob is a Buffer containing the serialized version.

util.deserialize(binaryBlob, callback)

deserializes a binary blob into the instance

callback must have the signature function (err, dagNode), where err is an Error if the function fails and dagNode is the dagNode that got deserialized in the process.

util.cid(binaryBlob[, options], callback)

get the CID of a binary blob

Options include:

callback must have the signature function (err, cid), where err is an Error if the function fails and cid is a CID instance of the binary blob.

Local resolver methods
resolver.resolve(binaryBlob, path, callback)

resolves a path in block, returns the value and or a link and the partial missing path. This way the IPLD Resolver can fetch the link and continue to resolve.

callback must have the signature function (err, result), where err is an Error if the function fails and result is an object with the following keys:

If path is the root /, the result is a nested object that contains all paths that tree() returns. The values are the same as accessing them directly with the full path. Example:

tree() returns:

thor/name", "author/email"]

resolve(binaryblob, "/", callback) would then have as a result:


uthor": {
"name": "vmx",
"email": "vmx@example.com"


Numbers within a path are interpreted as an array.

resolver.tree(binaryBlob[, options], callback)

returns all the paths available in this block.

Options include:

callback must have the signature function (err, result), where err is an Error if the function fails and result is a list of path such as ["/foo", "/bar", "/author/name", ...].

Properties
defaultHashAlg

Default hash algorithm of the format

Most formats have one specific hash algorithm, e.g. Bitcoin?s is dbl-sha2-256. CBOR can be used with any hash algorithm, though the default in the IPFS world is sha256. defaultHashAlg is used in the util.cid() call if no hash algorithm was given. The value of defaultHashAlg must be one defined in the Multihash Table.

multicodec

Identifier for the format implementation

The multicodec property is used to register a format implementation in IPLD. It needs to be one specified in the Multicodec Table.

Maintainers

Captain: @diasdavid.

Contribute

Feel free to join in. All welcome. Open an issue!

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to IPLD are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

This repository is only for documents. These are licensed under a CC-BY 3.0 Unported License © 2016 Protocol Labs Inc. Any code is licensed under a MIT © 2016 Protocol Labs Inc.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.