Documentation ¶
Index ¶
- Variables
- func VerifyProof(rootHash common.Hash, proof *ProofResult) (bool, error)
- func VerifyTrie(rootHash common.Hash, backend kv.Storage, cache PruneCache) (bool, error)
- type Iterator
- type JMT
- func (jmt *JMT) Commit(pruneArgs *PruneArgs) (rootHash common.Hash)
- func (jmt *JMT) Get(key []byte) ([]byte, error)
- func (jmt *JMT) PreloadTrieNodes(nodeKeys [][]byte)
- func (jmt *JMT) Prove(key []byte) (*ProofResult, error)
- func (jmt *JMT) Root() types.Node
- func (jmt *JMT) Update(version uint64, key, value []byte) error
- type ProofResult
- type PruneArgs
- type PruneCache
- type RawNode
- type TrieCache
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorTimeout = errors.New("wait too long when iterating trie") ErrorInterrupted = errors.New("interrupt iterating trie") ErrorNoMoreData = errors.New("no more trie data") )
View Source
var ( ErrorBadProof = errors.New("proof is invalid") // proof content or struct is illegal ErrorInvalidPath = errors.New("invalid merkle path") // addressing merkle path error whe generate proof ErrorNodeMissing = errors.New("node is missing") // miss node in merkle path )
View Source
var (
ErrorNotFound = errors.New("not found in DB")
)
Functions ¶
func VerifyProof ¶
func VerifyProof(rootHash common.Hash, proof *ProofResult) (bool, error)
VerifyProof support key existence proof
func VerifyTrie ¶
VerifyTrie verifies a whole trie
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator traverse whole jmt trie
func NewIterator ¶
func (*Iterator) IterateLeaf ¶
func (it *Iterator) IterateLeaf()
type JMT ¶
type JMT struct {
// contains filtered or unexported fields
}
func New ¶
func New(rootHash common.Hash, backend kv.Storage, trieCache TrieCache, pruneCache PruneCache, logger logrus.FieldLogger) (*JMT, error)
New load and init jmt from kv. Before New, there must be a mapping <rootHash, rootNodeKey> in kv.
func (*JMT) Get ¶
Get finds the value according to key in tree. If key isn't exist in tree, return nil with no error.
func (*JMT) PreloadTrieNodes ¶
todo: batch preload
type ProofResult ¶
type PruneArgs ¶
type PruneArgs struct { Enable bool // whether enable pruning or not Journal *types.TrieJournal // if Enable is true, jmt.Commit will set Journal }
type PruneCache ¶
type RawNode ¶
type RawNode struct { RawKey []byte // physical key of trie node in KV storage RawValue []byte // physical value of trie node in KV storage LeafKey []byte // non-empty iff current node is a leaf node, represents logical key of leaf LeafValue []byte // non-empty iff current node is a leaf node, represents logical value of leaf }
Click to show internal directories.
Click to hide internal directories.