fixedtree

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: GPL-3.0 Imports: 9 Imported by: 12

Documentation

Overview

Package fixedtree provides tree structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseNode

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

func EmptyBaseNode

func EmptyBaseNode() BaseNode

func NewBaseNode

func NewBaseNode(key string) BaseNode

func ParseBaseNodeString

func ParseBaseNodeString(s string) (n BaseNode, err error)

func (BaseNode) Equal

func (n BaseNode) Equal(b Node) bool

func (BaseNode) Hash

func (n BaseNode) Hash() util.Hash

func (BaseNode) IsEmpty

func (n BaseNode) IsEmpty() bool

func (BaseNode) IsValid

func (n BaseNode) IsValid([]byte) error

func (BaseNode) JSONMarshaler

func (n BaseNode) JSONMarshaler() BaseNodeJSONMarshaler

func (BaseNode) Key

func (n BaseNode) Key() string

func (BaseNode) MarshalJSON

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

func (BaseNode) SetHash

func (n BaseNode) SetHash(h util.Hash) Node

func (BaseNode) String

func (n BaseNode) String() string

func (*BaseNode) UnmarshalJSON

func (n *BaseNode) UnmarshalJSON(b []byte) error

type BaseNodeJSONMarshaler

type BaseNodeJSONMarshaler struct {
	Hash    util.Hash `json:"hash,omitempty"`
	Key     string    `json:"key,omitempty"`
	Isempty bool      `json:"isempty,omitempty"`
}

type Node

type Node interface {
	util.IsValider
	Key() string
	Hash() util.Hash
	Equal(Node) bool
	IsEmpty() bool
	SetHash(util.Hash) Node
}

func ExtractProofMaterial

func ExtractProofMaterial(nodes []Node, key string) (extracted []Node, err error)

type NodeWrite

type NodeWrite func(uint64, Node) error

type Proof

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

func NewProof

func NewProof(extracted []Node) Proof

func NewProofFromNodes

func NewProofFromNodes(nodes []Node, key string) (p Proof, err error)

func (Proof) IsValid

func (p Proof) IsValid(b []byte) error

func (Proof) MarshalJSON

func (p Proof) MarshalJSON() ([]byte, error)

func (Proof) Nodes

func (p Proof) Nodes() []Node

func (Proof) Prove

func (p Proof) Prove(key string) error

func (*Proof) UnmarshalJSON

func (p *Proof) UnmarshalJSON(b []byte) error

type Tree

type Tree struct {
	hint.BaseHinter
	// contains filtered or unexported fields
}

func EmptyTree

func EmptyTree() Tree

func NewTree

func NewTree(ht hint.Hint, nodes []Node) (Tree, error)

func (Tree) IsValid

func (t Tree) IsValid(b []byte) error

func (Tree) Len

func (t Tree) Len() int

func (Tree) Node

func (t Tree) Node(index uint64) Node

func (Tree) Nodes

func (t Tree) Nodes() []Node

func (Tree) Proof

func (t Tree) Proof(key string) (Proof, error)

func (Tree) Root

func (t Tree) Root() util.Hash

func (*Tree) Set

func (t *Tree) Set(index uint64, n Node) error

func (Tree) Traverse

func (t Tree) Traverse(f func(index uint64, node Node) (bool, error)) error

type Writer

type Writer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(ht hint.Hint, size uint64) (*Writer, error)

func (*Writer) Add

func (g *Writer) Add(index uint64, n Node) error

func (*Writer) Hint

func (g *Writer) Hint() hint.Hint

func (*Writer) Len

func (g *Writer) Len() int

func (*Writer) Root

func (g *Writer) Root() util.Hash

func (*Writer) Traverse

func (g *Writer) Traverse(f func(index uint64, node Node) (bool, error)) error

func (*Writer) Tree

func (g *Writer) Tree() (Tree, error)

func (*Writer) Write

func (g *Writer) Write(w NodeWrite) (err error)

Jump to

Keyboard shortcuts

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