cid

package
v0.0.0-...-12ab560 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Overview

Package cid - provides methods for ContentID struct.

ContentID is 32 bytes is a unique identifier of a file stored in a Filecoin blockchain network.

Package cid - provides methods for ContentIDAdapter struct.

ContentIDAdapter is 32 bytes is a unique identifier of a file stored in a Filecoin blockchain network.

Index

Constants

View Source
const WordSize = 32 // the ContentID length is 32 bytes.

Variables

This section is empty.

Functions

func MapCIDToString

func MapCIDToString(cids []ContentID) []string

Map - used to returns a new slice containing CIDs as string values

Types

type ContentID

type ContentID struct {
	// contains filtered or unexported fields
}

ContentID represents a CID.

func MapStringToCID

func MapStringToCID(cids []string) []ContentID

Map - used to returns a new slice containing CIDs as string values

func NewContentID

func NewContentID(id *big.Int) (*ContentID, error)

NewContentID creates a ContentID object.

func NewContentIDFromBytes

func NewContentIDFromBytes(id []byte) (*ContentID, error)

NewContentIDFromBytes creates a ContentID object from bytes array.

func NewContentIDFromHexString

func NewContentIDFromHexString(id string) (*ContentID, error)

NewContentIDFromHexString creates a ContentID object from hex string.

func NewRandomContentID

func NewRandomContentID() *ContentID

NewRandomContentID creates a random ContentID object.

func (ContentID) CalculateHash

func (n ContentID) CalculateHash() ([]byte, error)

CalculateHash hashes the values of a ContentID.

func (ContentID) Equals

func (n ContentID) Equals(other merkletree.Content) (bool, error)

Equals tests for equality of two ContentIDs.

func (ContentID) MarshalJSON

func (n ContentID) MarshalJSON() ([]byte, error)

MarshalJSON is used to marshal CID into bytes.

func (*ContentID) ToBytes

func (n *ContentID) ToBytes() []byte

ToBytes returns the byte array representation of the ContentID.

func (*ContentID) ToString

func (n *ContentID) ToString() string

ToString returns a string for the ContentID.

func (*ContentID) UnmarshalJSON

func (n *ContentID) UnmarshalJSON(p []byte) error

UnmarshalJSON is used to unmarshal bytes into ContentID.

type ContentIDAdapter

type ContentIDAdapter struct {
	Id string
}

ContentIDAdapter represents a CID.

func (ContentIDAdapter) CalculateHash

func (n ContentIDAdapter) CalculateHash() ([]byte, error)

CalculateHash hashes the values of a ContentIDAdapter.

func (ContentIDAdapter) Equals

func (n ContentIDAdapter) Equals(other merkletree.Content) (bool, error)

Equals tests for equality of two Contents

func (*ContentIDAdapter) ToString

func (n *ContentIDAdapter) ToString() string

ToString returns a string for the ContentID.

Jump to

Keyboard shortcuts

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