tree

package
v2.10.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTree

func CheckTree(t Tree) error

func CheckTreeRing

func CheckTreeRing(tr Tree) error

func CheckTreeSize

func CheckTreeSize(t Tree) error

func NewTree

func NewTree() *tree

func PrintBranchInfo

func PrintBranchInfo(b Branch) map[string]interface{}

func PrintTree

func PrintTree(b Tree) map[string]interface{}

func PrintTreeJson

func PrintTreeJson(b Tree) string

Types

type Branch

type Branch interface {
	BranchBase
	GetKnot(height uint64, flag bool) Knot
	GetHash(height uint64, flag bool) *common.Hash
	GetKnotAndBranch(height uint64) (Knot, Branch)
	GetHashAndBranch(height uint64) (*common.Hash, Branch)
	ContainsKnot(height uint64, hash common.Hash, flag bool) bool
	HeadHH() (uint64, common.Hash)
	TailHH() (uint64, common.Hash)
	Linked(root Branch) bool

	Size() uint64
	Root() Branch
	ID() string
	Type() BranchType
}

type BranchBase

type BranchBase interface {
	MatchHead(hash common.Hash) bool
	SprintTail() string
	SprintHead() string
	UTime() time.Time
}

type BranchType

type BranchType uint8
const (
	Normal BranchType = 0
	Disk              = 1
)

type Knot

type Knot interface {
	Height() uint64
	Hash() common.Hash
	PrevHash() common.Hash
}

type Tree

type Tree interface {
	Root() Branch
	Main() Branch
	Branches() map[string]Branch
	Brothers(b Branch) []Branch
	PruneTree() []Branch
	FindBranch(height uint64, hash common.Hash) Branch
	ForkBranch(b Branch, height uint64, hash common.Hash) Branch

	RootHeadAdd(k Knot) error

	AddHead(b Branch, k Knot) error
	RemoveTail(b Branch, k Knot) error
	AddTail(b Branch, k Knot) error

	SwitchMainTo(b Branch) error
	SwitchMainToEmpty() error
	FindForkPointFromMain(target Branch) (Knot, Knot, error)
	Init(name string, root Branch) error

	Exists(hash common.Hash) bool
	Size() uint64
}

Jump to

Keyboard shortcuts

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