ethereum

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: GPL-3.0, GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoreCacheSize = 20
	MaxHeaderLimit = 200000
	SplicingSymbol = "-"
)

Variables

This section is empty.

Functions

func CalcBaseFee

func CalcBaseFee(config *ethparams.ChainConfig, parent *Header) *big.Int

CalcBaseFee calculates the basefee of the header.

func InitHeaderStore

func InitHeaderStore(state types.StateDB, header *Header, td *big.Int) error

func VerifyEip1559Header

func VerifyEip1559Header(config *ethparams.ChainConfig, parent, header *Header) error

Types

type Cache

type Cache struct {
	Cache *lru.Cache
	// contains filtered or unexported fields
}
type Header struct {
	ParentHash  common.Hash      `json:"parentHash"       gencodec:"required"`
	UncleHash   common.Hash      `json:"sha3Uncles"       gencodec:"required"`
	Coinbase    common.Address   `json:"miner"            gencodec:"required"`
	Root        common.Hash      `json:"stateRoot"        gencodec:"required"`
	TxHash      common.Hash      `json:"transactionsRoot" gencodec:"required"`
	ReceiptHash common.Hash      `json:"receiptsRoot"     gencodec:"required"`
	Bloom       types.Bloom      `json:"logsBloom"        gencodec:"required"`
	Difficulty  *big.Int         `json:"difficulty"       gencodec:"required"`
	Number      *big.Int         `json:"number"           gencodec:"required"`
	GasLimit    uint64           `json:"gasLimit"         gencodec:"required"`
	GasUsed     uint64           `json:"gasUsed"          gencodec:"required"`
	Time        uint64           `json:"timestamp"        gencodec:"required"`
	Extra       []byte           `json:"extraData"        gencodec:"required"`
	MixDigest   common.Hash      `json:"mixHash"`
	Nonce       types.BlockNonce `json:"nonce"`

	// BaseFee was added by EIP-1559 and is ignored in legacy headers.
	BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
}

func (*Header) Hash

func (eh *Header) Hash() common.Hash

type HeaderStore

type HeaderStore struct {
	CanonicalNumberToHash map[uint64]common.Hash
	Headers               map[string][]byte
	TDs                   map[string]*big.Int
	CurNumber             uint64
	CurHash               common.Hash
}

func NewHeaderStore

func NewHeaderStore() *HeaderStore

func (*HeaderStore) CurrentHash

func (hs *HeaderStore) CurrentHash() common.Hash

func (*HeaderStore) CurrentNumber

func (hs *HeaderStore) CurrentNumber() uint64

func (*HeaderStore) DecodeRLP

func (hs *HeaderStore) DecodeRLP(s *rlp.Stream) error

func (*HeaderStore) DeleteCanonicalHash

func (hs *HeaderStore) DeleteCanonicalHash(number uint64)

func (*HeaderStore) EncodeRLP

func (hs *HeaderStore) EncodeRLP(w io.Writer) error

func (*HeaderStore) GetCurrentNumberAndHash

func (hs *HeaderStore) GetCurrentNumberAndHash(db types.StateDB) (uint64, common.Hash, error)

func (*HeaderStore) GetHashByNumber

func (hs *HeaderStore) GetHashByNumber(db types.StateDB, number uint64) (common.Hash, error)

func (*HeaderStore) GetHeader

func (hs *HeaderStore) GetHeader(hash common.Hash, number uint64) *Header

func (*HeaderStore) GetHeaderByNumber

func (hs *HeaderStore) GetHeaderByNumber(number uint64) *Header

func (*HeaderStore) GetTd

func (hs *HeaderStore) GetTd(hash common.Hash, number uint64) *big.Int

func (*HeaderStore) HasHeader

func (hs *HeaderStore) HasHeader(hash common.Hash, number uint64) bool

func (*HeaderStore) InsertHeaders

func (hs *HeaderStore) InsertHeaders(db types.StateDB, ethHeaders []byte) ([]*params.NumberHash, error)

func (*HeaderStore) Load

func (hs *HeaderStore) Load(state types.StateDB) (err error)

func (*HeaderStore) ReadCanonicalHash

func (hs *HeaderStore) ReadCanonicalHash(number uint64) common.Hash

func (*HeaderStore) ResetHeaderStore

func (hs *HeaderStore) ResetHeaderStore(state types.StateDB, ethHeaders []byte, td *big.Int) error

func (*HeaderStore) Store

func (hs *HeaderStore) Store(state types.StateDB) error

func (*HeaderStore) WriteCanonicalHash

func (hs *HeaderStore) WriteCanonicalHash(hash common.Hash, number uint64)

func (*HeaderStore) WriteHeader

func (hs *HeaderStore) WriteHeader(header *Header)

func (*HeaderStore) WriteHeaders

func (hs *HeaderStore) WriteHeaders(db types.StateDB, ethHeaders []byte) (*headerWriteResult, error)

func (*HeaderStore) WriteTd

func (hs *HeaderStore) WriteTd(hash common.Hash, number uint64, td *big.Int)

type TxProve

type TxProve struct {
	Receipt     *ethtypes.Receipt
	Prove       light.NodeList
	BlockNumber uint64
	TxIndex     uint
}

type Validate

type Validate struct{}

func (*Validate) ValidateHeaderChain

func (v *Validate) ValidateHeaderChain(db types.StateDB, headers []byte, chainType chains.ChainType) (int, error)

func (*Validate) VerifyHeaders

func (v *Validate) VerifyHeaders(hs *HeaderStore, headers []*Header, chainType chains.ChainType) (chan<- struct{}, <-chan error)

type Verify

type Verify struct {
}

func (*Verify) Verify

func (v *Verify) Verify(db types.StateDB, routerContractAddr common.Address, txProveBytes []byte) (logs []byte, err error)

type WriteStatus

type WriteStatus byte

WriteStatus status of write

const (
	NonStatTy WriteStatus = iota
	CanonStatTy
	SideStatTy
)

Jump to

Keyboard shortcuts

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