trienodes

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MarkChainedByKey is used as a value placeholder in a parent TrieNodes (PP), which indicates
	// that there is a child TrieNodes (CP) chained up in the PP with the key as the CP's root hash
	// and the value equals to this placeholder.
	MarkChainedByKey = markChained + byKey
	// MarkChainedByValue is used to prefix a value in a parent TrieNodes (PP), which indicates that
	// there is a child TrieNodes (CP) chained up in the PP with the prefix + CP's root hash as the
	// value in PP.
	MarkChainedByValue = markChained + byValue
)

Variables

View Source
var (
	// ErrTrieCycleDetected is the error returned when trie cycle is detected
	ErrTrieCycleDetected = errors.New("trie cycle detected")
	// ErrTrieTraversalStopped is the error returned when trie traversal is stopped by a callback
	// function
	ErrTrieTraversalStopped = errors.New("trie traversal stopped")
	// ErrTrieRawKeyMissing is the error when a trie raw key is missing
	ErrTrieRawKeyMissing = errors.New("trie raw key missing")
)

Functions

func ChainByKey

func ChainByKey() []byte

ChainByKey returns the value to indicate that the key of the value should be used as the descendent key that is the root of the child trie

func ChainByValue

func ChainByValue(value []byte) []byte

ChainByValue marks the value as chained by key, where the value will be used as the descendent key that is the root of the child trie

func IsChainedByKey

func IsChainedByKey(value []byte) bool

IsChainedByKey indicates whether the value is a meta value that means chained by key

func IsChainedByValue

func IsChainedByValue(value []byte) (key []byte, ok bool)

IsChainedByValue indicates whether the value is chained by value. If so, the descendent key will be returned, and the ok will be true

func VerifyChainedTrieNodesStore

func VerifyChainedTrieNodesStore(option VerifyTrieNodesStoreOption) error

VerifyChainedTrieNodesStore verifies the chained trie nodes contained in the store. If it succeeds, it will return a set of key-value pairs the chained trie nodes contains, after which it is up to the caller to verify the key-value pairs. The `KeySep` in each `KeyValue` can be used to access the key within each tries

func VerifyTrieNodesStore

func VerifyTrieNodesStore(option VerifyTrieNodesStoreOption) error

VerifyTrieNodesStore verifies the trie nodes contained in the store. If it succeeds, it will return a set of key-value pairs the trie nodes contains, after which it is up to the caller to verify the key-value pairs

Types

type ChainedBy

type ChainedBy int

ChainedBy represents a chained by type

const (
	// NotChained is not chained
	NotChained ChainedBy = iota
	// ChainedByKey is chained by key
	ChainedByKey
	// ChainedByValue is chained by value
	ChainedByValue
)

func GetChainedBy

func GetChainedBy(value []byte) (key []byte, tp ChainedBy)

GetChainedBy gets the value's descendent key and chained by type. When the type is ChainedByKey, the returned key is nil, and the user should use the key that is used to retrieve the value as the descendent key

type OnKeyValueFunc

type OnKeyValueFunc func(kv apiPB.KeyValue) error

OnKeyValueFunc represents the function type that is called whenever a key-value is retrieved during a traversal. Return an error will stop the traversal. To halt the traversal earlier, return a ErrTrieTraversalStopped

type OnTrieNodeFunc

type OnTrieNodeFunc func(rawKey, rawValue []byte) error

OnTrieNodeFunc represents the function type that is called whenever a trie node is retrieved during a traversal. Return an error will stop the traversal. To halt the traversal earlier, return a ErrTrieTraversalStopped

type VerifyTrieNodesStoreOption

type VerifyTrieNodesStoreOption struct {
	Store      ethdb.KeyValueReader
	Node       trie.Node
	OnTrieNode OnTrieNodeFunc
	OnKeyValue OnKeyValueFunc
	// contains filtered or unexported fields
}

VerifyTrieNodesStoreOption represents the options for VerifyProof

Jump to

Keyboard shortcuts

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