triedb

package
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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeTypeBranch = 3

NodeTypeBranch ...

View Source
var NodeTypeEmpty = 0

NodeTypeEmpty ...

View Source
var NodeTypeExtension = 2

NodeTypeExtension ...

View Source
var NodeTypeLeaf = 1

NodeTypeLeaf ...

Functions

func ConsumeCommonPrefix

func ConsumeCommonPrefix(left []uint8, right []uint8) [][]uint8

ConsumeCommonPrefix ...

func EncodeNode

func EncodeNode(node Node, codec InterfaceCodec) []uint8

EncodeNode ...

func GetCommonPrefixLength

func GetCommonPrefixLength(left []uint8, right []uint8) int

GetCommonPrefixLength ...

func GetNodeType

func GetNodeType(node Node) int

GetNodeType ...

func IsBranchNode

func IsBranchNode(node interface{}) bool

IsBranchNode ...

func IsEmptyNode

func IsEmptyNode(node interface{}) bool

IsEmptyNode ...

func IsExtensionNode

func IsExtensionNode(node Node) bool

IsExtensionNode ...

func IsKvNode

func IsKvNode(node interface{}) bool

IsKvNode ...

func IsLeafNode

func IsLeafNode(node Node) bool

IsLeafNode ...

func IsMultiSlice

func IsMultiSlice(value interface{}) bool

IsMultiSlice ...

func IsNull

func IsNull(node interface{}) bool

IsNull ...

func KeyEquals

func KeyEquals(key []uint8, test []uint8) bool

KeyEquals ...

func KeyStartsWith

func KeyStartsWith(key []uint8, partial []uint8) bool

KeyStartsWith ...

func NewFirstUint8ListFromNode

func NewFirstUint8ListFromNode(node Node) []uint8

NewFirstUint8ListFromNode ...

func NewUint8FromNode

func NewUint8FromNode(value interface{}) []uint8

NewUint8FromNode ...

func NewUint8ListFromNode

func NewUint8ListFromNode(value interface{}) [][]uint8

NewUint8ListFromNode ...

func Size

func Size(value interface{}) int

Size ...

Types

type Checkpoint

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

Checkpoint ...

func NewCheckpoint

func NewCheckpoint(rootHash []byte) *Checkpoint

NewCheckpoint ...

func (*Checkpoint) CommitCheckpoint

func (c *Checkpoint) CommitCheckpoint() []byte

CommitCheckpoint ...

func (*Checkpoint) CreateCheckpoint

func (c *Checkpoint) CreateCheckpoint() []byte

CreateCheckpoint ...

func (*Checkpoint) RevertCheckpoint

func (c *Checkpoint) RevertCheckpoint() []byte

RevertCheckpoint ...

func (*Checkpoint) RootHash

func (c *Checkpoint) RootHash() []byte

RootHash ...

func (*Checkpoint) TxRoot

func (c *Checkpoint) TxRoot() []byte

TxRoot ...

type EncodedPath

type EncodedPath []uint8

EncodedPath ...

func ComputeExtensionKey

func ComputeExtensionKey(nibbles []uint8) EncodedPath

ComputeExtensionKey ...

func ComputeLeafKey

func ComputeLeafKey(nibbles []uint8) EncodedPath

ComputeLeafKey ...

func NewBlankBranch

func NewBlankBranch() []EncodedPath

NewBlankBranch ...

func NewEncodedPath

func NewEncodedPath(value []uint8) EncodedPath

NewEncodedPath ...

type Impl

type Impl struct {
	Debug bool
	// contains filtered or unexported fields
}

Impl ...

func NewImpl

func NewImpl(db db.TXDB, rootHash []byte, codec InterfaceCodec) *Impl

NewImpl ...

func (*Impl) DebugLog

func (i *Impl) DebugLog(ifcs ...interface{})

DebugLog ...

func (*Impl) Del

func (i *Impl) Del(node Node, trieKey []uint8) Node

Del ...

func (*Impl) DelBranchNode

func (i *Impl) DelBranchNode(inode Node, trieKey []uint8) Node

DelBranchNode ... NOTE: node must be NodeBranch NOTE: node branch must have 17 items, either single dimension array or nil

func (*Impl) DelKvNode

func (i *Impl) DelKvNode(node Node, trieKey []uint8) Node

DelKvNode ... NOTE: node should be two item kv slice

func (*Impl) Get

func (i *Impl) Get(node Node, trieKey []uint8) Node

Get ...

func (*Impl) GetBranchNode

func (i *Impl) GetBranchNode(node []Node, trieKey []uint8) Node

GetBranchNode ...

func (*Impl) GetKvNode

func (i *Impl) GetKvNode(node []Node, trieKey []uint8) Node

GetKvNode ... NOTE: kv nodes only hold two items

func (*Impl) GetNode

func (i *Impl) GetNode(hash interface{}) Node

GetNode ... NOTE: should usually be single dimension array

func (*Impl) NodeToDBMapping

func (i *Impl) NodeToDBMapping(node Node) (interface{}, []uint8)

NodeToDBMapping ... NOTE: return can be single dimension or nil or same node back with no value

func (*Impl) NormalizeBranchNode

func (i *Impl) NormalizeBranchNode(node []Node) Node

NormalizeBranchNode ... NOTE: node can be either NodeKv | NodeBranch

func (*Impl) PersistNode

func (i *Impl) PersistNode(node Node) Node

PersistNode ... NOTE: Node should nil or single dimension array

func (*Impl) Put

func (i *Impl) Put(node Node, trieKey []uint8, value []uint8) Node

Put ...

func (*Impl) PutBranchNode

func (i *Impl) PutBranchNode(node Node, trieKey []uint8, value []uint8) Node

PutBranchNode ...

func (*Impl) PutKvNode

func (i *Impl) PutKvNode(node []Node, trieKey []uint8, value []uint8) Node

PutKvNode ... NOTE: KV node should be two item list

func (*Impl) SetDebug

func (i *Impl) SetDebug(enabled bool)

SetDebug ...

func (*Impl) SetRootNode

func (i *Impl) SetRootNode(node Node)

SetRootNode ...

func (*Impl) Snapshot

func (i *Impl) Snapshot(dest *TrieDB, fn db.ProgressCB, root []byte, keys int, percent int, depth int) int

Snapshot ...

type InterfaceCodec

type InterfaceCodec interface {
	Encode(value interface{}) ([]uint8, error)
	Decode(encoded []byte, decoded interface{}) error
}

InterfaceCodec ....

type InterfaceTrieDB

type InterfaceTrieDB interface {
	GetRoot() []uint8
	SetRoot(rootHash []uint8)
	Snapshot(dest *TrieDB, fn db.ProgressCB) int64
}

InterfaceTrieDB ....

type Node

type Node interface{}

Node ..

func DecodeNode

func DecodeNode(encoded Node, codec InterfaceCodec) Node

DecodeNode ...

func NewNode

func NewNode(value interface{}) Node

NewNode ...

func NewNodeListFromNode

func NewNodeListFromNode(node Node) []Node

NewNodeListFromNode ...

func NewNodeListFromUint8

func NewNodeListFromUint8(values [][]uint8) []Node

NewNodeListFromUint8 ...

type NodeEncoded

type NodeEncoded struct{}

NodeEncoded ...

type NodeType

type NodeType int

NodeType ...

type RLPCodec

type RLPCodec struct {
	Name string
}

RLPCodec ...

func NewRLPCodec

func NewRLPCodec() *RLPCodec

NewRLPCodec ...

func (*RLPCodec) Decode

func (r *RLPCodec) Decode(encoded []byte, result interface{}) error

Decode ...

func (*RLPCodec) Encode

func (r *RLPCodec) Encode(value interface{}) ([]uint8, error)

Encode ...

type TrieCodec

type TrieCodec struct {
	Name string
}

TrieCodec ...

func NewTrieCodec

func NewTrieCodec() *TrieCodec

NewTrieCodec ...

func (*TrieCodec) Decode

func (r *TrieCodec) Decode(encoded []byte, result interface{}) error

Decode ...

func (*TrieCodec) Encode

func (r *TrieCodec) Encode(value interface{}) ([]uint8, error)

Encode ...

type TrieDB

type TrieDB struct {
	Debug bool
	// contains filtered or unexported fields
}

TrieDB ...

func NewTrieDB

func NewTrieDB(db db.TXDB, rootHash []byte, codec InterfaceCodec) *TrieDB

NewTrieDB ...

func (*TrieDB) Close

func (t *TrieDB) Close()

Close ...

func (*TrieDB) DebugLog

func (t *TrieDB) DebugLog(i ...interface{})

DebugLog ...

func (*TrieDB) Del

func (t *TrieDB) Del(key []uint8)

Del ...

func (*TrieDB) Drop

func (t *TrieDB) Drop()

Drop ...

func (*TrieDB) Empty

func (t *TrieDB) Empty()

Empty ...

func (*TrieDB) Get

func (t *TrieDB) Get(key []uint8) []uint8

Get ...

func (*TrieDB) GetNode

func (t *TrieDB) GetNode(hash []byte) Node

GetNode ...

func (*TrieDB) GetRoot

func (t *TrieDB) GetRoot() []byte

GetRoot ...

func (*TrieDB) Maintain

func (t *TrieDB) Maintain(fn *db.ProgressCB) error

Maintain ...

func (*TrieDB) Open

func (t *TrieDB) Open()

Open ...

func (*TrieDB) Put

func (t *TrieDB) Put(key, value []uint8)

Put ...

func (*TrieDB) Rename

func (t *TrieDB) Rename(base, file string)

Rename ...

func (*TrieDB) SetDebug

func (t *TrieDB) SetDebug(enabled bool)

SetDebug ...

func (*TrieDB) SetRoot

func (t *TrieDB) SetRoot(rootHash []byte)

SetRoot ...

func (*TrieDB) Size

func (t *TrieDB) Size() int

Size ...

func (*TrieDB) Snapshot

func (t *TrieDB) Snapshot(dest *TrieDB, fn db.ProgressCB) int

Snapshot ...

func (*TrieDB) Transaction

func (t *TrieDB) Transaction(fn func() bool) (bool, error)

Transaction ...

type TxDB

type TxDB struct {
	db.MemoryDB
}

TxDB ...

Jump to

Keyboard shortcuts

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