tree

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyProof = types.Proof{}
)

Functions

This section is empty.

Types

type AppendOnlyTree

type AppendOnlyTree struct {
	*Tree
	// contains filtered or unexported fields
}

AppendOnlyTree is a tree where leaves are added sequentially (by index)

func NewAppendOnlyTree

func NewAppendOnlyTree(db *sql.DB, dbPrefix string) *AppendOnlyTree

NewAppendOnlyTree creates a AppendOnlyTree

func (*AppendOnlyTree) AddLeaf

func (t *AppendOnlyTree) AddLeaf(tx db.Txer, blockNum, blockPosition uint64, leaf types.Leaf) error

type Tree

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

func (*Tree) GetLastRoot

func (t *Tree) GetLastRoot(tx db.Querier) (types.Root, error)

GetLastRoot returns the last processed root

func (*Tree) GetLeaf

func (t *Tree) GetLeaf(tx db.Querier, index uint32, root common.Hash) (common.Hash, error)

func (*Tree) GetProof

func (t *Tree) GetProof(ctx context.Context, index uint32, root common.Hash) (types.Proof, error)

GetProof returns the merkle proof for a given index and root.

func (*Tree) GetRootByHash

func (t *Tree) GetRootByHash(ctx context.Context, hash common.Hash) (*types.Root, error)

GetRootByHash returns the root associated to the hash

func (*Tree) GetRootByIndex

func (t *Tree) GetRootByIndex(ctx context.Context, index uint32) (types.Root, error)

GetRootByIndex returns the root associated to the index

func (*Tree) Reorg

func (t *Tree) Reorg(tx db.Txer, firstReorgedBlock uint64) error

Reorg deletes all the data relevant from firstReorgedBlock (includded) and onwards

type UpdatableTree

type UpdatableTree struct {
	*Tree
}

UpdatableTree is a tree that have updatable leaves, and doesn't need to have sequential inserts

func NewUpdatableTree

func NewUpdatableTree(db *sql.DB, dbPrefix string) *UpdatableTree

NewUpdatableTree returns an UpdatableTree

func (*UpdatableTree) UpsertLeaf

func (t *UpdatableTree) UpsertLeaf(tx db.Txer, blockNum, blockPosition uint64, leaf types.Leaf) (common.Hash, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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