gethdatalayer

package module
v0.0.0-...-c744afd Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

README

Geth-data-layer

Go library to access the geth stored data.

Usage

package main

import (
	"fmt"

	gethdatalayer "github.com/umbracle/geth-data-layer"
)

func main() {
	path := "..../chaindata" // path to the storage data

	store, err := gethdatalayer.NewStore(path)
	if err != nil {
		panic(err)
	}

	iter := store.Iterator()
	// iter.Seek(1000000)

	for iter.Next() {
		val, _ := iter.Value()
		fmt.Println(val.Number)
	}
}

There are three storage interaces:

  • NewAncientStore: Access the ancient store data.
  • NewLevelDbStore: Access the leveldb store data.
  • NewStore: Abstraction on top of the leveldb and ancient data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessEntry

type AccessEntry struct {
	Address address
	Storage []hash
}

type AccessList

type AccessList []AccessEntry

func (*AccessList) UnmarshalRLPWith

func (a *AccessList) UnmarshalRLPWith(v *fastrlp.Value) error

type AncientStore

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

func NewAncientStore

func NewAncientStore(path string) (*AncientStore, error)

func (*AncientStore) Iterator

func (a *AncientStore) Iterator() Iterator

func (*AncientStore) LastNum

func (a *AncientStore) LastNum() uint64

type Block

type Block struct {
	Number   uint64
	Header   *Header
	Body     *Body
	Receipts Receipts
}

type Body

type Body struct {
	Transactions []*Transaction
	Uncles       []*Header
}

func (*Body) UnmarshalRLP

func (b *Body) UnmarshalRLP(input []byte) error

func (*Body) UnmarshalRLPFrom

func (b *Body) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error
type Header struct {
	Hash         hash
	ParentHash   hash
	Sha3Uncles   hash
	Miner        address
	StateRoot    hash
	TxRoot       hash
	ReceiptsRoot hash
	LogsBloom    [32]byte
	Difficulty   uint64
	Number       uint64
	GasLimit     uint64
	GasUsed      uint64
	Timestamp    uint64
	ExtraData    []byte
	MixHash      hash
	Nonce        [8]byte
	BaseFee      *big.Int
}

func (*Header) UnmarshalRLP

func (h *Header) UnmarshalRLP(input []byte) error

func (*Header) UnmarshalRLPFrom

func (h *Header) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

type Iterator

type Iterator interface {
	Seek(num uint64)
	Next() bool
	Value() (*Block, error)
}

type LevelDbStore

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

func NewLevelDBStore

func NewLevelDBStore(path string) (*LevelDbStore, error)

func (*LevelDbStore) Get

func (l *LevelDbStore) Get(k []byte) ([]byte, error)

func (*LevelDbStore) Iterator

func (l *LevelDbStore) Iterator() Iterator

type Log

type Log struct {
	Address address
	Topics  []hash
	Data    []byte
}

func (*Log) UnmarshalRLPFrom

func (l *Log) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

type Receipt

type Receipt struct {
	PostStateOrStatus []byte
	CumulativeGasUsed uint64
	Logs              []*Log
}

func (*Receipt) UnmarshalRLP

func (r *Receipt) UnmarshalRLP(input []byte) error

func (*Receipt) UnmarshalRLPFrom

func (r *Receipt) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

UnmarshalRLP unmarshals a Receipt in RLP format

type Receipts

type Receipts []*Receipt

func (*Receipts) UnmarshalRLP

func (r *Receipts) UnmarshalRLP(input []byte) error

func (*Receipts) UnmarshalRLPFrom

func (r *Receipts) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

type Store

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

func NewStore

func NewStore(path string) (*Store, error)

func (*Store) Iterator

func (s *Store) Iterator() Iterator

type Transaction

type Transaction struct {
	Type TransactionType

	// legacy values
	Hash     hash
	From     address
	To       *address
	Input    []byte
	GasPrice uint64
	Gas      uint64
	Value    *big.Int
	Nonce    uint64
	V        []byte
	R        []byte
	S        []byte

	// eip-2930 values
	ChainID    *big.Int
	AccessList AccessList

	// eip-1559 values
	MaxPriorityFeePerGas *big.Int
	MaxFeePerGas         *big.Int
}

func (*Transaction) UnmarshalRLP

func (t *Transaction) UnmarshalRLP(buf []byte) error

func (*Transaction) UnmarshalRLPFrom

func (t *Transaction) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

type TransactionType

type TransactionType int
const (
	TransactionLegacy TransactionType = 0
	// eip-2930
	TransactionAccessList TransactionType = 1
	// eip-1559
	TransactionDynamicFee TransactionType = 2
)

Jump to

Keyboard shortcuts

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