Help us shape the future of Go! Take the 2026 Go Developer Survey

types

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 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 added in v0.8.0

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 added in v0.8.0

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 added in v0.8.0

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

NewProof creates a proof from an array of hashes

func (Proof) String added in v0.8.0

func (p Proof) String() string

type ReadTreer added in v0.8.0

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 added in v0.8.0

type ReorganizeTreer interface {
	ReadTreer
	Reorg(tx dbtypes.Txer, firstReorgedBlock uint64) error
	BackwardToIndex(ctx context.Context, tx dbtypes.Txer, targetIndex uint32) 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