merkle

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatechainBlocksKindStr ...
	StatechainBlocksKindStr = "statechainBlocks"
	// MainchainBlocksKindStr ...
	MainchainBlocksKindStr = "mainchainBlocks"
	// TransactionsKindStr ...
	TransactionsKindStr = "transactions"
	// DiffsKindStr ...
	DiffsKindStr = "diffs"
	// MerkleTreesKindStr ...
	MerkleTreesKindStr = "merkleTrees"
)

Variables

View Source
var (
	// ErrUnknownKind ...
	ErrUnknownKind = errors.New("unknown kind")
	// ErrNilChainObjects ...
	ErrNilChainObjects = errors.New("nil chain objects")
	// ErrNilChainObject ...
	ErrNilChainObject = errors.New("nil chain object")
	// ErrInconsistentKinds ...
	ErrInconsistentKinds = errors.New("inconsistent kinds")
	// ErrNilMerkleTree ...
	ErrNilMerkleTree = errors.New("merkle tree is nil")
	// ErrNilMerkleTreeRootHash ...
	ErrNilMerkleTreeRootHash = errors.New("merkle tree hash is nil")
	// ErrNilProps ...
	ErrNilProps = errors.New("props are nil")
)

Functions

func BuildCoderFromBytes

func BuildCoderFromBytes(data []byte) (*coder.MerkleTree, error)

BuildCoderFromBytes ...

func BuildCoderFromTree

func BuildCoderFromTree(t *Tree) *coder.MerkleTree

BuildCoderFromTree ...

Types

type Tree

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

Tree ...

func BuildFromObjects

func BuildFromObjects(chainObjects []merkletree.Content, kind string) (*Tree, error)

BuildFromObjects ... note: using this method to keep with our New function accepting props TODO: ensure that all of the kinds are the same? TODO ensure that the kind is the true kind?

func New

func New(props *TreeProps) (*Tree, error)

New ...

func (*Tree) CalculateHash

func (t *Tree) CalculateHash() (string, error)

CalculateHash ... note: this function doesn't actually calculate the hash but returns the root hash

func (*Tree) CalculateHashBytes

func (t *Tree) CalculateHashBytes() ([]byte, error)

CalculateHashBytes ...

func (*Tree) Deserialize

func (t *Tree) Deserialize(data []byte) error

Deserialize ...

func (*Tree) DeserializeString

func (t *Tree) DeserializeString(hexStr string) error

DeserializeString ...

func (*Tree) Equals

func (t *Tree) Equals(other merkletree.Content) (bool, error)

Equals ...

func (*Tree) MarshalJSON

func (t *Tree) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Tree) Props

func (t *Tree) Props() TreeProps

Props ...

func (*Tree) Serialize

func (t *Tree) Serialize() ([]byte, error)

Serialize ...

func (*Tree) SerializeString

func (t *Tree) SerializeString() (string, error)

SerializeString ...

func (*Tree) SetHash

func (t *Tree) SetHash() error

SetHash ...

func (*Tree) UnmarshalJSON

func (t *Tree) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type TreeProps

type TreeProps struct {
	MerkleTreeRootHash *string
	Kind               string
	Hashes             []string
}

TreeProps ...

func BuildTreePropsFromBytes

func BuildTreePropsFromBytes(data []byte) (*TreeProps, error)

BuildTreePropsFromBytes ...

func BuildTreePropsFromCoder

func BuildTreePropsFromCoder(tmp *coder.MerkleTree) (*TreeProps, error)

BuildTreePropsFromCoder ...

Jump to

Keyboard shortcuts

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