tree

package
v2.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 11 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 NewMockBranchRoot

func NewMockBranchRoot() *mockBranchRoot

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) *types.Hash
	GetKnotAndBranch(height uint64) (Knot, Branch)
	GetHashAndBranch(height uint64) (*types.Hash, Branch)
	ContainsKnot(height uint64, hash types.Hash, flag bool) bool
	HeadHH() (uint64, types.Hash)
	TailHH() (uint64, types.Hash)
	Linked(root Branch) bool

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

type BranchBase

type BranchBase interface {
	MatchHead(hash types.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() types.Hash
	PrevHash() types.Hash
}

type Tree

type Tree interface {
	Root() Branch
	Main() Branch
	Branches() map[string]Branch
	Brothers(b Branch) []Branch
	PruneTree() []Branch
	FindBranch(height uint64, hash types.Hash) Branch
	ForkBranch(b Branch, height uint64, hash types.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 types.Hash) bool
	Size() uint64
}

Jump to

Keyboard shortcuts

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