types

package
v0.0.0-...-383178a Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)
View Source
const BloomByteLength = 256

Variables

View Source
var (
	// EmptyRootHash is the root when there are no transactions
	EmptyRootHash = StringToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")

	// EmptyUncleHash is the root when there are no uncles
	EmptyUncleHash = StringToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
)
View Source
var HeaderHash func(h *Header) Hash
View Source
var ZeroAddress = Address{}
View Source
var ZeroHash = Hash{}

Functions

func AddressToString

func AddressToString(address Address) string

func EncodeBigInt

func EncodeBigInt(b *big.Int) *string

func EncodeBytes

func EncodeBytes(b []byte) *string

func EncodeUint64

func EncodeUint64(b uint64) *string

func MarshalRLPTo

func MarshalRLPTo(obj marshalRLPFunc, dst []byte) []byte

func ParseBytes

func ParseBytes(val *string) ([]byte, error)

func ParseInt64orHex

func ParseInt64orHex(val *string) (int64, error)

func ParseUint256orHex

func ParseUint256orHex(val *string) (*big.Int, error)

func ParseUint64orHex

func ParseUint64orHex(val *string) (uint64, error)

func UnmarshalRlp

func UnmarshalRlp(obj unmarshalRLPFunc, input []byte) error

Types

type Address

type Address [AddressLength]byte

func BytesToAddress

func BytesToAddress(b []byte) Address

func StringToAddress

func StringToAddress(str string) Address

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

func (Address) Ptr

func (a Address) Ptr() *Address

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(input []byte) error

UnmarshalText parses an address in hex syntax.

type Block

type Block struct {
	Header       *Header
	Transactions []*Transaction
	Uncles       []*Header
	// contains filtered or unexported fields
}

func (*Block) Body

func (b *Block) Body() *Body

func (*Block) Hash

func (b *Block) Hash() Hash

func (*Block) MarshalRLP

func (b *Block) MarshalRLP() []byte

func (*Block) MarshalRLPTo

func (b *Block) MarshalRLPTo(dst []byte) []byte

func (*Block) MarshalRLPWith

func (b *Block) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value

func (*Block) Number

func (b *Block) Number() uint64

func (*Block) ParentHash

func (b *Block) ParentHash() Hash

func (*Block) Size

func (b *Block) Size() uint64

func (*Block) String

func (b *Block) String() string

func (*Block) UnmarshalRLP

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

func (*Block) UnmarshalRLPFrom

func (b *Block) UnmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error

func (*Block) WithSeal

func (b *Block) WithSeal(header *Header) *Block

WithSeal returns a new block with the data from b but the header replaced with the sealed one.

type Bloom

type Bloom [BloomByteLength]byte

func CreateBloom

func CreateBloom(receipts []*Receipt) (b Bloom)

CreateBloom creates a new bloom filter from a set of receipts

func (*Bloom) IsLogInBloom

func (b *Bloom) IsLogInBloom(log *Log) bool

IsLogInBloom checks if the log has a possible presence in the bloom filter

func (Bloom) MarshalText

func (b Bloom) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Bloom) String

func (b Bloom) String() string

func (*Bloom) UnmarshalText

func (b *Bloom) UnmarshalText(input []byte) error

type Body

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

func (*Body) MarshalRLPTo

func (b *Body) MarshalRLPTo(dst []byte) []byte

func (*Body) MarshalRLPWith

func (b *Body) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value

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 Hash

type Hash [HashLength]byte

func BytesToHash

func BytesToHash(b []byte) Hash

func StringToHash

func StringToHash(str string) Hash

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

type Header struct {
	ParentHash   Hash
	Sha3Uncles   Hash
	Miner        []byte
	StateRoot    Hash
	TxRoot       Hash
	ReceiptsRoot Hash
	LogsBloom    Bloom
	Difficulty   uint64
	Number       uint64
	GasLimit     uint64
	GasUsed      uint64
	Timestamp    uint64
	ExtraData    []byte
	MixHash      Hash
	Nonce        Nonce
	Hash         Hash
}

Header represents a block header in the Ethereum blockchain.

func (*Header) ComputeHash

func (h *Header) ComputeHash() *Header

ComputeHash computes the hash of the header

func (*Header) Copy

func (h *Header) Copy() *Header

func (*Header) Equal

func (h *Header) Equal(hh *Header) bool

func (*Header) HasBody

func (h *Header) HasBody() bool

func (*Header) HasReceipts

func (h *Header) HasReceipts() bool

func (*Header) IsGenesis

func (h *Header) IsGenesis() bool

func (*Header) MarshalRLP

func (h *Header) MarshalRLP() []byte

func (*Header) MarshalRLPTo

func (h *Header) MarshalRLPTo(dst []byte) []byte

func (*Header) MarshalRLPWith

func (h *Header) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith marshals the header to RLP with a specific fastrlp.Arena

func (*Header) SetNonce

func (h *Header) SetNonce(i uint64)

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 Log

type Log struct {
	Address Address
	Topics  []Hash
	Data    []byte
}

func (*Log) MarshalRLPWith

func (l *Log) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value

func (*Log) UnmarshalRLPFrom

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

type Nonce

type Nonce [8]byte

func (Nonce) MarshalText

func (n Nonce) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (Nonce) String

func (n Nonce) String() string

type RLPMarshaler

type RLPMarshaler interface {
	MarshalRLPTo(dst []byte) []byte
}

type RLPStoreMarshaler

type RLPStoreMarshaler interface {
	MarshalStoreRLPTo(dst []byte) []byte
}

type RLPStoreUnmarshaler

type RLPStoreUnmarshaler interface {
	UnmarshalStoreRLP(input []byte) error
}

type RLPUnmarshaler

type RLPUnmarshaler interface {
	UnmarshalRLP(input []byte) error
}

type Receipt

type Receipt struct {
	// consensus fields
	Root              Hash
	CumulativeGasUsed uint64
	LogsBloom         Bloom
	Logs              []*Log
	Status            *ReceiptStatus

	// context fields
	GasUsed         uint64
	ContractAddress *Address
	TxHash          Hash
}

func (*Receipt) MarshalLogsWith

func (r *Receipt) MarshalLogsWith(a *fastrlp.Arena) *fastrlp.Value

MarshalLogsWith marshals the logs of the receipt to RLP with a specific fastrlp.Arena

func (*Receipt) MarshalRLP

func (r *Receipt) MarshalRLP() []byte

func (*Receipt) MarshalRLPTo

func (r *Receipt) MarshalRLPTo(dst []byte) []byte

func (*Receipt) MarshalRLPWith

func (r *Receipt) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith marshals a receipt with a specific fastrlp.Arena

func (*Receipt) MarshalStoreRLPTo

func (r *Receipt) MarshalStoreRLPTo(dst []byte) []byte

func (*Receipt) MarshalStoreRLPWith

func (r *Receipt) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value

func (*Receipt) SetContractAddress

func (r *Receipt) SetContractAddress(contractAddress Address)

func (*Receipt) SetStatus

func (r *Receipt) SetStatus(s ReceiptStatus)

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

func (*Receipt) UnmarshalStoreRLP

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

func (*Receipt) UnmarshalStoreRLPFrom

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

type ReceiptStatus

type ReceiptStatus uint64
const (
	ReceiptFailed ReceiptStatus = iota
	ReceiptSuccess
)

type Receipts

type Receipts []*Receipt

func (Receipts) MarshalRLPTo

func (r Receipts) MarshalRLPTo(dst []byte) []byte

func (*Receipts) MarshalRLPWith

func (r *Receipts) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value

func (Receipts) MarshalStoreRLPTo

func (r Receipts) MarshalStoreRLPTo(dst []byte) []byte

func (*Receipts) MarshalStoreRLPWith

func (r *Receipts) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value

func (*Receipts) UnmarshalRLP

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

func (*Receipts) UnmarshalRLPFrom

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

func (*Receipts) UnmarshalStoreRLP

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

func (*Receipts) UnmarshalStoreRLPFrom

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

type Transaction

type Transaction struct {
	Nonce    uint64
	GasPrice *big.Int
	Gas      uint64
	To       *Address
	Value    *big.Int
	Input    []byte
	V        *big.Int
	R        *big.Int
	S        *big.Int
	Hash     Hash
	From     Address
	// contains filtered or unexported fields
}

func (*Transaction) ComputeHash

func (t *Transaction) ComputeHash() *Transaction

ComputeHash computes the hash of the transaction

func (*Transaction) Copy

func (t *Transaction) Copy() *Transaction

func (*Transaction) Cost

func (t *Transaction) Cost() *big.Int

Cost returns gas * gasPrice + value

func (*Transaction) ExceedsBlockGasLimit

func (t *Transaction) ExceedsBlockGasLimit(blockGasLimit uint64) bool

func (*Transaction) IsContractCreation

func (t *Transaction) IsContractCreation() bool

IsContractCreation checks if tx is contract creation

func (*Transaction) IsUnderpriced

func (t *Transaction) IsUnderpriced(priceLimit uint64) bool

func (*Transaction) MarshalRLP

func (t *Transaction) MarshalRLP() []byte

func (*Transaction) MarshalRLPTo

func (t *Transaction) MarshalRLPTo(dst []byte) []byte

func (*Transaction) MarshalRLPWith

func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith marshals the transaction to RLP with a specific fastrlp.Arena

func (*Transaction) MarshalStoreRLPTo

func (t *Transaction) MarshalStoreRLPTo(dst []byte) []byte

func (*Transaction) MarshalStoreRLPWith

func (t *Transaction) MarshalStoreRLPWith(a *fastrlp.Arena) *fastrlp.Value

func (*Transaction) Size

func (t *Transaction) Size() uint64

func (*Transaction) UnmarshalRLP

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

func (*Transaction) UnmarshalRLPFrom

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

UnmarshalRLPFrom unmarshals a Transaction in RLP format

func (*Transaction) UnmarshalStoreRLP

func (t *Transaction) UnmarshalStoreRLP(input []byte) error

func (*Transaction) UnmarshalStoreRLPFrom

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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