Documentation
¶
Overview ¶
Package block encodes and decodes OrbitDB's dag-cbor blocks.
It plays the role multiformats/block plays in @orbitdb/core: values are encoded as canonical dag-cbor and addressed by a CIDv1 (dag-cbor codec, sha2-256) rendered in base58btc, e.g. "zdpu...".
Values are plain Go values. Encoding accepts nil, bool, integers, floats, string, []byte, cid.Cid, slices, arrays, maps with string keys and datamodel.Node; other types (structs, pointers) are converted through encoding/json first. Decoding produces nil, bool, int64, float64, string, []byte, cid.Cid, []any and map[string]any.
Numbers follow JavaScript semantics so blocks re-encode identically on both sides: a float with an integral value in the safe-integer range is encoded as an integer, exactly as @ipld/dag-cbor encodes a JS number.
Index ¶
- func CID(data []byte) (cid.Cid, error)
- func Decode(data []byte) (any, error)
- func Encode(v any) (hash string, data []byte, err error)
- func FromNode(n datamodel.Node) (any, error)
- func Hash(data []byte) (string, error)
- func Int(m map[string]any, key string) (int64, error)
- func Map(v any) (map[string]any, error)
- func String(m map[string]any, key string) (string, error)
- func Strings(m map[string]any, key string) ([]string, error)
- func ToNode(v any) (datamodel.Node, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hash ¶
Hash returns the base58btc string of the CID of data, the form OrbitDB uses for entry, identity and manifest hashes.
Types ¶
This section is empty.