Documentation ¶
Index ¶
- Variables
- type BNBSparseMerkleTree
- func (tree *BNBSparseMerkleTree) Clear(recentVersion *Version) (err error)
- func (tree *BNBSparseMerkleTree) Commit(recentVersion *Version) (Version, error)
- func (tree *BNBSparseMerkleTree) Get(key uint64, version *Version) ([]byte, error)
- func (tree *BNBSparseMerkleTree) GetProof(key uint64) (Proof, error)
- func (tree *BNBSparseMerkleTree) IsEmpty() bool
- func (tree *BNBSparseMerkleTree) LatestVersion() Version
- func (tree *BNBSparseMerkleTree) MultiSet(items []Item) error
- func (tree *BNBSparseMerkleTree) RecentVersion() Version
- func (tree *BNBSparseMerkleTree) Reset()
- func (tree *BNBSparseMerkleTree) Rollback(version Version) error
- func (tree *BNBSparseMerkleTree) Root() []byte
- func (tree *BNBSparseMerkleTree) Set(key uint64, val []byte) error
- func (tree *BNBSparseMerkleTree) Size() uint64
- func (tree *BNBSparseMerkleTree) VerifyProof(key uint64, proof Proof) bool
- type Hasher
- type InternalNode
- type Item
- type Option
- type Proof
- type SparseMerkleTree
- type StorageLeafNode
- type StorageTreeNode
- type TreeNode
- func (node *TreeNode) ComputeInternalHash()
- func (node *TreeNode) Copy() *TreeNode
- func (node *TreeNode) IsTemporary() bool
- func (node *TreeNode) PreviousVersion() Version
- func (node *TreeNode) Prune(oldestVersion Version) uint64
- func (node *TreeNode) Release(oldestVersion Version) uint64
- func (node *TreeNode) Rollback(targetVersion Version) (bool, uint64)
- func (node *TreeNode) Root() []byte
- func (node *TreeNode) Set(hash []byte, version Version)
- func (node *TreeNode) SetChildren(child *TreeNode, nibble int, version Version)
- func (node *TreeNode) Size() uint64
- func (node *TreeNode) ToStorageTreeNode() *StorageTreeNode
- type Version
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEmptyRoot = errors.New("empty root") ErrVersionTooOld = errors.New("the version is lower than the rollback version") ErrVersionTooHigh = errors.New("the version is higher than the latest version") ErrNodeNotFound = errors.New("tree node not found") ErrVersionMismatched = errors.New("the version is mismatched with the database") ErrUnexpected = errors.New("unexpected error") ErrInvalidKey = errors.New("invalid key") ErrInvalidDepth = errors.New("depth must be a multiple of 4") ErrExtendNode = errors.New("extending node error") )
Functions ¶
This section is empty.
Types ¶
type BNBSparseMerkleTree ¶
type BNBSparseMerkleTree struct {
// contains filtered or unexported fields
}
func (*BNBSparseMerkleTree) Clear ¶ added in v0.0.4
func (tree *BNBSparseMerkleTree) Clear(recentVersion *Version) (err error)
func (*BNBSparseMerkleTree) Commit ¶
func (tree *BNBSparseMerkleTree) Commit(recentVersion *Version) (Version, error)
func (*BNBSparseMerkleTree) Get ¶
func (tree *BNBSparseMerkleTree) Get(key uint64, version *Version) ([]byte, error)
func (*BNBSparseMerkleTree) GetProof ¶
func (tree *BNBSparseMerkleTree) GetProof(key uint64) (Proof, error)
func (*BNBSparseMerkleTree) IsEmpty ¶
func (tree *BNBSparseMerkleTree) IsEmpty() bool
func (*BNBSparseMerkleTree) LatestVersion ¶
func (tree *BNBSparseMerkleTree) LatestVersion() Version
func (*BNBSparseMerkleTree) MultiSet ¶
func (tree *BNBSparseMerkleTree) MultiSet(items []Item) error
MultiSet sets k,v pairs in parallel
1. generate all intermediate nodes, with lock; 2. set all leaves, without lock; 3. re-compute hash, from leaves to root
func (*BNBSparseMerkleTree) RecentVersion ¶
func (tree *BNBSparseMerkleTree) RecentVersion() Version
func (*BNBSparseMerkleTree) Reset ¶
func (tree *BNBSparseMerkleTree) Reset()
func (*BNBSparseMerkleTree) Rollback ¶
func (tree *BNBSparseMerkleTree) Rollback(version Version) error
func (*BNBSparseMerkleTree) Root ¶
func (tree *BNBSparseMerkleTree) Root() []byte
func (*BNBSparseMerkleTree) Set ¶
func (tree *BNBSparseMerkleTree) Set(key uint64, val []byte) error
func (*BNBSparseMerkleTree) Size ¶
func (tree *BNBSparseMerkleTree) Size() uint64
func (*BNBSparseMerkleTree) VerifyProof ¶
func (tree *BNBSparseMerkleTree) VerifyProof(key uint64, proof Proof) bool
type InternalNode ¶
type InternalNode []byte
type Option ¶
type Option func(*BNBSparseMerkleTree)
Option is a function that configures SMT.
func BatchSizeLimit ¶
func DBCacheSize ¶
func EnableMetrics ¶
func GCThreshold ¶
func GoRoutinePool ¶
func GoRoutinePool(pool *ants.Pool) Option
func InitializeVersion ¶
type SparseMerkleTree ¶
type SparseMerkleTree interface { Size() uint64 Get(key uint64, version *Version) ([]byte, error) Set(key uint64, val []byte) error MultiSet(items []Item) error IsEmpty() bool Root() []byte GetProof(key uint64) (Proof, error) VerifyProof(key uint64, proof Proof) bool LatestVersion() Version RecentVersion() Version Reset() Clear(recentVersion *Version) error Commit(recentVersion *Version) (Version, error) Rollback(version Version) error }
func NewBNBSparseMerkleTree ¶
func NewSparseMerkleTree ¶
type StorageLeafNode ¶
type StorageLeafNode struct {
Versions []*VersionInfo `rlp:"optional"`
}
type StorageTreeNode ¶
type StorageTreeNode struct { Children [16]*StorageLeafNode `rlp:"optional"` Internals [14]InternalNode `rlp:"optional"` Versions []*VersionInfo `rlp:"optional"` Path uint64 `rlp:"optional"` }
func (*StorageTreeNode) ToTreeNode ¶
func (node *StorageTreeNode) ToTreeNode(depth uint8, nilHashes *nilHashes, hasher *Hasher) *TreeNode
type TreeNode ¶
type TreeNode struct { Children [16]*TreeNode Internals [14]InternalNode Versions []*VersionInfo // contains filtered or unexported fields }
func NewTreeNode ¶
func (*TreeNode) ComputeInternalHash ¶
func (node *TreeNode) ComputeInternalHash()
Recompute all internal hashes
func (*TreeNode) IsTemporary ¶
The nodes without child data. will be extended when it needs to be searched down.
func (*TreeNode) PreviousVersion ¶
PreviousVersion returns the previous version number in the current TreeNode
func (*TreeNode) Release ¶
Release nodes that have not been updated for a long time from memory. slowing down memory usage in runtime.
func (*TreeNode) SetChildren ¶
func (*TreeNode) ToStorageTreeNode ¶
func (node *TreeNode) ToStorageTreeNode() *StorageTreeNode
type VersionInfo ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.