triecodec

package
Version: v0.0.0-...-f5f0bdb Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BRANCH_NODE_NO_VALUE = 254

BRANCH_NODE_NO_VALUE ...

View Source
const BRANCH_NODE_WITH_VALUE = 255

BRANCH_NODE_WITH_VALUE ...

View Source
const BranchValueIndex = 16

BranchValueIndex ...

View Source
const EMPTY_TRIE = 0

EMPTY_TRIE ...

View Source
const EXTENSION_NODE_BIG = 253

EXTENSION_NODE_BIG ...

View Source
const EXTENSION_NODE_OFFSET = 128

EXTENSION_NODE_OFFSET ...

View Source
const EXTENSION_NODE_SMALL_MAX = EXTENSION_NODE_BIG - 1

EXTENSION_NODE_SMALL_MAX ...

View Source
const EXTENSION_NODE_THRESHOLD = EXTENSION_NODE_BIG - EXTENSION_NODE_OFFSET // 125

EXTENSION_NODE_THRESHOLD ...

View Source
const LEAF_NODE_BIG = 127

LEAF_NODE_BIG ...

View Source
const LEAF_NODE_OFFSET = 1

LEAF_NODE_OFFSET ...

View Source
const LEAF_NODE_SMALL_MAX = LEAF_NODE_BIG - 1

LEAF_NODE_SMALL_MAX ...

View Source
const LEAF_NODE_THRESHOLD = LEAF_NODE_BIG - LEAF_NODE_OFFSET

LEAF_NODE_THRESHOLD ...

View Source
const NODE_TYPE_BRANCH = 1

NODE_TYPE_BRANCH ...

View Source
const NODE_TYPE_EXT = 2

NODE_TYPE_EXT ...

View Source
const NODE_TYPE_LEAF = 3

NODE_TYPE_LEAF ...

View Source
const NODE_TYPE_NULL = 0

NODE_TYPE_NULL ...

View Source
const Type = "Substrate"

Type ...

Variables

View Source
var (
	// HPFlag2 ...
	HPFlag2 uint8 = 2
	// HPFlag0 ...
	HPFlag0 uint8
	// NibbleTerminator ...
	NibbleTerminator uint8 = 16
	// NeedsTerminator ...
	NeedsTerminator = []uint8{HPFlag2, HPFlag2 + 1}
	// IsOddLength ...
	IsOddLength = []uint8{HPFlag0 + 1, HPFlag2 + 1}
)
View Source
var (
	// ExtensionNodeBig ...
	ExtensionNodeBig = 253
	// ExtensionNodeOffset ...
	ExtensionNodeOffset = 128
	// LeafNodeBig ...
	LeafNodeBig = 127
	// LeafNodeOffset ...
	LeafNodeOffset = 1
	// MaxFuseLength ...
	MaxFuseLength = 255 + 126
)
View Source
var ErrTypeAssertion = errors.New("Cannot assert type")

ErrTypeAssertion ...

View Source
var ErrUnreachableCode = errors.New("Unreachable code")

ErrUnreachableCode ...

Functions

func AddNibblesTerminator

func AddNibblesTerminator(nibbles []uint8) []uint8

AddNibblesTerminator ...

func CreateBranch

func CreateBranch(value []uint8, hasChildren []bool) []uint8

CreateBranch ...

func CreateEmpty

func CreateEmpty() []uint8

CreateEmpty ...

func CreateExtension

func CreateExtension(key []uint8) []uint8

CreateExtension ...

func CreateLeaf

func CreateLeaf(key []uint8, value []uint8) []uint8

CreateLeaf ...

func CreateSubstream

func CreateSubstream(value []uint8) []uint8

CreateSubstream ...

func CreateValue

func CreateValue(value []uint8) []uint8

CreateValue ...

func Decode

func Decode(input []uint8) interface{}

Decode ...

func DecodeNibbles

func DecodeNibbles(value []uint8) []uint8

DecodeNibbles ....

func DecodeNodeHeader

func DecodeNodeHeader(input interface{}) (int, interface{})

DecodeNodeHeader ...

func DecodeNodeHeaderUint8Slice

func DecodeNodeHeaderUint8Slice(input []uint8) (int, interface{})

DecodeNodeHeaderUint8Slice ...

func DecodeNodeHeaderUint8Slices

func DecodeNodeHeaderUint8Slices(input []interface{}) (int, interface{})

DecodeNodeHeaderUint8Slices ...

func Encode

func Encode(input []interface{}) []uint8

Encode ...

func EncodeNibbles

func EncodeNibbles(nibbles []uint8) []uint8

EncodeNibbles ...

func EndBranch

func EndBranch() []uint8

EndBranch ...

func ExtractKey

func ExtractKey(key []uint8) []uint8

ExtractKey ...

func ExtractNodeKey

func ExtractNodeKey(node [][]uint8) []uint8

ExtractNodeKey ...

func FromNibbles

func FromNibbles(input []uint8) []uint8

FromNibbles converts the uint8 slice input from nibbles. Calculate and return a uint8 slice that's made from a list of nibbles.

func FuseNibbles

func FuseNibbles(nibbles []uint8, isLeaf bool) []uint8

FuseNibbles ...

func Hashing

func Hashing(value []byte) []byte

Hashing ...

func Includes

func Includes(haystack []uint8, needle uint8) bool

Includes ...

func IsNibblesTerminated

func IsNibblesTerminated(nibbles []uint8) bool

IsNibblesTerminated ...

func RemoveNibblesTerminator

func RemoveNibblesTerminator(nibbles []uint8) []uint8

RemoveNibblesTerminator ...

func SharedPrefixLength

func SharedPrefixLength(first []uint8, second []uint8) int

SharedPrefixLength returns the shared prefix length. Calculates the minimum distance that both uint8 slices share.

func ToNibbles

func ToNibbles(input []uint8) []uint8

ToNibbles converts the uint8 slice input to nibbles. Calculate and return a list of nibbles that makes up the input.

Types

type BranchHeader

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

BranchHeader ...

func NewBranchHeader

func NewBranchHeader(value bool) *BranchHeader

NewBranchHeader ...

func (*BranchHeader) Value

func (b *BranchHeader) Value() bool

Value ....

type ExtensionHeader

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

ExtensionHeader ...

func NewExtensionHeader

func NewExtensionHeader(value int) *ExtensionHeader

NewExtensionHeader ...

type LeafHeader

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

LeafHeader ...

func NewLeafHeader

func NewLeafHeader(value int) *LeafHeader

NewLeafHeader ...

type NodeHeader

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

NodeHeader ...

func NewNodeHeader

func NewNodeHeader(input interface{}) *NodeHeader

NewNodeHeader ...

func (*NodeHeader) EncodedLength

func (n *NodeHeader) EncodedLength() int

EncodedLength ...

func (*NodeHeader) NodeType

func (n *NodeHeader) NodeType() int

NodeType ...

func (*NodeHeader) ToUint8Slice

func (n *NodeHeader) ToUint8Slice() []uint8

ToUint8Slice ...

func (*NodeHeader) Value

func (n *NodeHeader) Value() int

Value ...

type Null

type Null struct {
}

Null ...

func NewNull

func NewNull() *Null

NewNull ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL