Documentation
¶
Index ¶
- func BlockGasCost(b *ethtypes.Block) *big.Int
- func SetHeaderExtra(h *ethtypes.Header, extra *HeaderExtra)
- func WithHeaderExtra(h *ethtypes.Header, extra *HeaderExtra) *ethtypes.Header
- type HeaderExtra
- func (h *HeaderExtra) DecodeJSON(eth *ethtypes.Header, input []byte) error
- func (h *HeaderExtra) DecodeRLP(eth *ethtypes.Header, stream *rlp.Stream) error
- func (h *HeaderExtra) EncodeJSON(eth *ethtypes.Header) ([]byte, error)
- func (h *HeaderExtra) EncodeRLP(eth *ethtypes.Header, writer io.Writer) error
- func (h *HeaderExtra) PostCopy(dst *ethtypes.Header)
- type HeaderSerializable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetHeaderExtra ¶
func SetHeaderExtra(h *ethtypes.Header, extra *HeaderExtra)
SetHeaderExtra sets the given HeaderExtra on the [Header].
func WithHeaderExtra ¶
func WithHeaderExtra(h *ethtypes.Header, extra *HeaderExtra) *ethtypes.Header
WithHeaderExtra sets the given HeaderExtra on the [Header] and returns the [Header] for chaining.
Types ¶
type HeaderExtra ¶
HeaderExtra is a struct that contains extra fields used by Subnet-EVM in the block header. This type uses HeaderSerializable to encode and decode the extra fields along with the upstream type for compatibility with existing network blocks.
func GetHeaderExtra ¶
func GetHeaderExtra(h *ethtypes.Header) *HeaderExtra
GetHeaderExtra returns the HeaderExtra from the given [Header].
func (*HeaderExtra) DecodeJSON ¶
func (h *HeaderExtra) DecodeJSON(eth *ethtypes.Header, input []byte) error
DecodeJSON JSON decodes from the `input` bytes and writes the output to both the ethtypes.Header passed as argument and to the receiver HeaderExtra.
func (*HeaderExtra) DecodeRLP ¶
DecodeRLP RLP decodes from the *rlp.Stream and writes the output to both the ethtypes.Header passed as argument and to the receiver HeaderExtra.
func (*HeaderExtra) EncodeJSON ¶
func (h *HeaderExtra) EncodeJSON(eth *ethtypes.Header) ([]byte, error)
EncodeJSON JSON encodes the given ethtypes.Header and HeaderExtra together to the `writer`. It does merge both structs into a single HeaderSerializable.
func (*HeaderExtra) EncodeRLP ¶
EncodeRLP RLP encodes the given ethtypes.Header and HeaderExtra together to the `writer`. It does merge both structs into a single HeaderSerializable.
func (*HeaderExtra) PostCopy ¶
func (h *HeaderExtra) PostCopy(dst *ethtypes.Header)
type HeaderSerializable ¶
type HeaderSerializable 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 ethtypes.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 ethtypes.BlockNonce `json:"nonce"` // BaseFee was added by EIP-1559 and is ignored in legacy headers. BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` // BlockGasCost was added by SubnetEVM and is ignored in legacy // headers. BlockGasCost *big.Int `json:"blockGasCost" rlp:"optional"` // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` }
HeaderSerializable defines the header of a block in the Ethereum blockchain, as it is to be serialized into RLP and JSON. Note it must be exported so that rlpgen can generate the serialization code from it.
func (*HeaderSerializable) Hash ¶
func (h *HeaderSerializable) Hash() common.Hash
Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding. This function MUST be exported and is used in [HeaderSerializable.EncodeJSON] which is generated to the file gen_header_json.go.
func (HeaderSerializable) MarshalJSON ¶
func (h HeaderSerializable) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*HeaderSerializable) UnmarshalJSON ¶
func (h *HeaderSerializable) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.