util

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndSplitMetadata

func CheckAndSplitMetadata(ctx context.Context, nd ipld.Node, ds ipld.DAGService, meta bool) (ipld.Node, ipld.Node, error)

checkAndSplitMetadata returns both data root node and metadata root node if exists from the DAG topped by the given 'nd'. Case #1: if 'nd' is dummy root with metadata root node and user data root node being children,

return [the second data root child node, the first metadata root child node, nil].

Case #2: if 'nd' is metadata and the given `meta` is true, return [nil, nd, nil]. Otherwise return error. Case #3: if 'nd' is user data, return ['nd', nil, nil].

func CreateMetadataList

func CreateMetadataList(metaBytes []byte, dirTreeBytes []byte) []byte

CreateMetadataList join the given two byte array element into a final list format as BTFS metadata.

  1. Append the above `dirTreeBytes` byte array to metaBytes so that the final encoded output can ebable strings.SplitAfterN(encodedOutput, "},{", 2) to have two strings, to be processed separately with json.Unmarshal().
  2. Ensure metaBytes has two sections, each enclosed within curly bracket pair. E.g., `{"price":11.0},{}`. This will make the encoder task easy.

The precondition is to pass nil to `metaBytes` if no value exist for regular metadata, nil to `dirTreeBytes` for directoy tree bytes in case of Reed-Solomon directory inpuyt,

func EqualKeySets

func EqualKeySets(m map[string]interface{}, inputKeys []string) bool

EqualKeySets returns true if the key set of the given `m` equals the given key string array `inputKeys`.

func GetMetadataElement

func GetMetadataElement(bytes []byte) []byte

func GetMetadataList

func GetMetadataList(bytes []byte) ([]byte, []byte, error)

GetMetadataSList splits the given encoded metadata `bytes` into two byte arrays in JSON format. Note that chunker.RsMetaMap.IsDir indicates or true when the second array has contents.

func GetSerializedDirectoryElement

func GetSerializedDirectoryElement(bytes []byte) []byte

func Intersects

func Intersects(m map[string]interface{}, inputM map[string]interface{}) bool

Intersects returns true if the given two maps intersect.

func IsMetadataEmpty

func IsMetadataEmpty(b []byte) bool

func KeyIntersects

func KeyIntersects(m map[string]interface{}, inputKeys []string) bool

KeyIntersects returns true if the key set of the given `m` and the string array `inputKeys` intersects.

func ReadMetadataElementFromDag

func ReadMetadataElementFromDag(ctx context.Context, root ipld.Node, ds ipld.DAGService, meta bool) ([]byte, error)

func ReadMetadataListFromDag

func ReadMetadataListFromDag(ctx context.Context, root ipld.Node, ds ipld.DAGService, meta bool) ([]byte, []byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL