@@ -13,10 +13,13 @@ import (
1313 "github.com/ava-labs/libevm/rlp"
1414)
1515
16+ // GetHeaderExtra returns the [HeaderExtra] from the given [Header].
1617func GetHeaderExtra (h * Header ) * HeaderExtra {
1718 return extras .Header .Get (h )
1819}
1920
21+ // WithHeaderExtra sets the given [HeaderExtra] on the [Header],
22+ // and returns the header `h`. Note `h` is modified in place.
2023func WithHeaderExtra (h * Header , extra * HeaderExtra ) * Header {
2124 extras .Header .Set (h , extra )
2225 return h
@@ -32,6 +35,8 @@ type HeaderExtra struct {
3235 BlockGasCost * big.Int
3336}
3437
38+ // EncodeRLP RLP encodes the given [ethtypes.Header] and [HeaderExtra] together
39+ // to the `writer`. It does merge both structs into a single [HeaderSerializable].
3540func (h * HeaderExtra ) EncodeRLP (eth * ethtypes.Header , writer io.Writer ) error {
3641 temp := new (HeaderSerializable )
3742
@@ -41,6 +46,8 @@ func (h *HeaderExtra) EncodeRLP(eth *ethtypes.Header, writer io.Writer) error {
4146 return rlp .Encode (writer , temp )
4247}
4348
49+ // DecodeRLP RLP decodes from the [*rlp.Stream] and writes the output to both the
50+ // [ethtypes.Header] passed as argument and to the receiver [HeaderExtra].
4451func (h * HeaderExtra ) DecodeRLP (eth * ethtypes.Header , stream * rlp.Stream ) error {
4552 temp := new (HeaderSerializable )
4653 if err := stream .Decode (temp ); err != nil {
@@ -53,6 +60,8 @@ func (h *HeaderExtra) DecodeRLP(eth *ethtypes.Header, stream *rlp.Stream) error
5360 return nil
5461}
5562
63+ // EncodeJSON JSON encodes the given [ethtypes.Header] and [HeaderExtra] together
64+ // to the `writer`. It does merge both structs into a single [HeaderSerializable].
5665func (h * HeaderExtra ) EncodeJSON (eth * ethtypes.Header ) ([]byte , error ) {
5766 temp := new (HeaderSerializable )
5867
@@ -62,6 +71,8 @@ func (h *HeaderExtra) EncodeJSON(eth *ethtypes.Header) ([]byte, error) {
6271 return temp .EncodeJSON ()
6372}
6473
74+ // DecodeJSON JSON decodes from the `input` bytes and writes the output to both the
75+ // [ethtypes.Header] passed as argument and to the receiver [HeaderExtra].
6576func (h * HeaderExtra ) DecodeJSON (eth * ethtypes.Header , input []byte ) error {
6677 temp := new (HeaderSerializable )
6778 if err := temp .DecodeJSON (input ); err != nil {
0 commit comments