Documentation ¶
Overview ¶
Package tree provides tree structures.
Index ¶
- Variables
- func FixedTreeNodeHash(self, left, right FixedTreeNode) ([]byte, error)
- func ProveFixedTreeProof(pr []FixedTreeNode) error
- type BaseFixedTreeNode
- func (no BaseFixedTreeNode) Equal(n FixedTreeNode) bool
- func (no BaseFixedTreeNode) Hash() []byte
- func (no BaseFixedTreeNode) Index() uint64
- func (no BaseFixedTreeNode) IsValid([]byte) error
- func (no BaseFixedTreeNode) Key() []byte
- func (no BaseFixedTreeNode) M() map[string]interface{}
- func (no BaseFixedTreeNode) MarshalBSON() ([]byte, error)
- func (no BaseFixedTreeNode) MarshalJSON() ([]byte, error)
- func (no BaseFixedTreeNode) SetHash(h []byte) FixedTreeNode
- func (no *BaseFixedTreeNode) UnmarshalBSON(b []byte) error
- func (no *BaseFixedTreeNode) UnmarshalJSON(b []byte) error
- type BaseFixedTreeNodeBSONUnpacker
- type BaseFixedTreeNodeJSONPacker
- type BaseFixedTreeNodeJSONUnpacker
- type FixedTree
- func (tr FixedTree) IsValid([]byte) error
- func (tr FixedTree) Len() int
- func (tr FixedTree) MarshalBSON() ([]byte, error)
- func (tr FixedTree) MarshalJSON() ([]byte, error)
- func (tr FixedTree) Node(index uint64) (FixedTreeNode, error)
- func (tr FixedTree) Proof(index uint64) ([]FixedTreeNode, error)
- func (tr FixedTree) Root() []byte
- func (tr FixedTree) Traverse(f func(FixedTreeNode) (bool, error)) error
- func (tr *FixedTree) UnpackBSON(b []byte, enc *bsonenc.Encoder) error
- func (tr *FixedTree) UnpackJSON(b []byte, enc *jsonenc.Encoder) error
- type FixedTreeBSONUnpacker
- type FixedTreeGenerator
- type FixedTreeJSONPacker
- type FixedTreeJSONUnpacker
- type FixedTreeNode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FixedTreeType = hint.Type("fixedtree") FixedTreeHint = hint.NewHint(FixedTreeType, "v0.0.1") FixedTreeHinter = FixedTree{BaseHinter: hint.NewBaseHinter(FixedTreeHint)} )
View Source
var ( InvalidNodeError = util.NewError("invalid node") NoParentError = util.NewError("no node parent") EmptyNodeInTreeError = util.NewError("empty node found in tree") EmptyKeyError = util.NewError("empty node key") EmptyHashError = util.NewError("empty node hash") NoChildrenError = util.NewError("no children") HashNotMatchError = util.NewError("hash not match") InvalidProofError = util.NewError("invalid proof") )
Functions ¶
func FixedTreeNodeHash ¶
func FixedTreeNodeHash( self, left, right FixedTreeNode, ) ([]byte, error)
func ProveFixedTreeProof ¶
func ProveFixedTreeProof(pr []FixedTreeNode) error
Types ¶
type BaseFixedTreeNode ¶
type BaseFixedTreeNode struct { hint.BaseHinter // contains filtered or unexported fields }
func NewBaseFixedTreeNode ¶
func NewBaseFixedTreeNode(ht hint.Hint, index uint64, key []byte) BaseFixedTreeNode
func NewBaseFixedTreeNodeWithHash ¶
func NewBaseFixedTreeNodeWithHash(ht hint.Hint, index uint64, key, hash []byte) BaseFixedTreeNode
func (BaseFixedTreeNode) Equal ¶
func (no BaseFixedTreeNode) Equal(n FixedTreeNode) bool
func (BaseFixedTreeNode) Hash ¶
func (no BaseFixedTreeNode) Hash() []byte
func (BaseFixedTreeNode) Index ¶
func (no BaseFixedTreeNode) Index() uint64
func (BaseFixedTreeNode) IsValid ¶
func (no BaseFixedTreeNode) IsValid([]byte) error
func (BaseFixedTreeNode) Key ¶
func (no BaseFixedTreeNode) Key() []byte
func (BaseFixedTreeNode) M ¶
func (no BaseFixedTreeNode) M() map[string]interface{}
func (BaseFixedTreeNode) MarshalBSON ¶
func (no BaseFixedTreeNode) MarshalBSON() ([]byte, error)
func (BaseFixedTreeNode) MarshalJSON ¶
func (no BaseFixedTreeNode) MarshalJSON() ([]byte, error)
func (BaseFixedTreeNode) SetHash ¶
func (no BaseFixedTreeNode) SetHash(h []byte) FixedTreeNode
func (*BaseFixedTreeNode) UnmarshalBSON ¶
func (no *BaseFixedTreeNode) UnmarshalBSON(b []byte) error
func (*BaseFixedTreeNode) UnmarshalJSON ¶
func (no *BaseFixedTreeNode) UnmarshalJSON(b []byte) error
type BaseFixedTreeNodeJSONPacker ¶
type BaseFixedTreeNodeJSONPacker struct { jsonenc.HintedHead IN uint64 `json:"index"` KY string `json:"key"` HS string `json:"hash"` }
type FixedTree ¶
type FixedTree struct { hint.BaseHinter // contains filtered or unexported fields }
func EmptyFixedTree ¶
func EmptyFixedTree() FixedTree
func NewFixedTree ¶
func NewFixedTree(nodes []FixedTreeNode) FixedTree
func NewFixedTreeWithHint ¶
func NewFixedTreeWithHint(ht hint.Hint, nodes []FixedTreeNode) FixedTree
func (FixedTree) MarshalBSON ¶
func (FixedTree) MarshalJSON ¶
func (FixedTree) Proof ¶
func (tr FixedTree) Proof(index uint64) ([]FixedTreeNode, error)
Proof returns the nodes to prove whether node is in tree. It always returns root node + N(2 children).
func (*FixedTree) UnpackBSON ¶
type FixedTreeBSONUnpacker ¶
type FixedTreeGenerator ¶
func NewFixedTreeGenerator ¶
func NewFixedTreeGenerator(size uint64) *FixedTreeGenerator
func (*FixedTreeGenerator) Add ¶
func (tr *FixedTreeGenerator) Add(n FixedTreeNode) error
func (*FixedTreeGenerator) Tree ¶
func (tr *FixedTreeGenerator) Tree() (FixedTree, error)
type FixedTreeJSONPacker ¶
type FixedTreeJSONPacker struct { jsonenc.HintedHead NS []FixedTreeNode `json:"nodes"` }
type FixedTreeJSONUnpacker ¶
type FixedTreeJSONUnpacker struct {
NS json.RawMessage `json:"nodes"`
}
type FixedTreeNode ¶
Click to show internal directories.
Click to hide internal directories.