types

package
v0.8.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHeight uint8 = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FullTreer

type FullTreer interface {
	ReadTreer
	LeafWriter
	ReorganizeTreer
}

FullTreer = fully-capable tree (read, write, reorg)

type Leaf

type Leaf struct {
	Index uint32
	Hash  common.Hash
}

type LeafWriter

type LeafWriter interface {
	PutLeaf(tx dbtypes.Txer, blockNum, blockPosition uint64, leaf Leaf) (common.Hash, error)
}

LeafWriter provides write access to a Merkle tree.

type Proof

type Proof [DefaultHeight]common.Hash

func NewProof

func NewProof(proofRaw [DefaultHeight][common.HashLength]byte) Proof

NewProof creates a proof from an array of hashes

func (Proof) String

func (p Proof) String() string

type ReadTreer

type ReadTreer interface {
	GetRootByIndex(ctx context.Context, index uint32) (Root, error)
	GetRootByHash(ctx context.Context, hash common.Hash) (*Root, error)
	GetLastRoot(tx dbtypes.Querier) (Root, error)
	GetLeaf(tx dbtypes.Querier, index uint32, root common.Hash) (common.Hash, error)
	GetProof(ctx context.Context, index uint32, root common.Hash) (Proof, error)
}

ReadTreer provides read-only access to a Merkle tree.

type ReorganizeTreer

type ReorganizeTreer interface {
	ReadTreer
	Reorg(tx dbtypes.Txer, firstReorgedBlock uint64) error
}

ReorganizeTreer provides reorg handling for a Merkle tree.

type Root

type Root struct {
	Hash          common.Hash `meddler:"hash,hash"`
	Index         uint32      `meddler:"position"`
	BlockNum      uint64      `meddler:"block_num"`
	BlockPosition uint64      `meddler:"block_position"`
}

func (*Root) String added in v0.4.0

func (r *Root) String() string

type TreeNode

type TreeNode struct {
	Hash  common.Hash `meddler:"hash,hash"`
	Left  common.Hash `meddler:"left,hash"`
	Right common.Hash `meddler:"right,hash"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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