core/types: add inclusion list types

This commit is contained in:
Marius van der Wijden 2024-03-21 05:40:09 +01:00
parent 226fe5c203
commit f27bd687b9
4 changed files with 63 additions and 6 deletions

View file

@ -174,7 +174,7 @@ type Body struct {
Transactions []*Transaction Transactions []*Transaction
Uncles []*Header Uncles []*Header
Withdrawals []*Withdrawal `rlp:"optional"` Withdrawals []*Withdrawal `rlp:"optional"`
InclusionListSummary []*InclusionListEntry InclusionListSummary []*InclusionListEntry `rlp:"optional"`
} }
// Block represents an Ethereum block. // Block represents an Ethereum block.
@ -217,7 +217,7 @@ type extblock struct {
Txs []*Transaction Txs []*Transaction
Uncles []*Header Uncles []*Header
Withdrawals []*Withdrawal `rlp:"optional"` Withdrawals []*Withdrawal `rlp:"optional"`
InclusionListSummary []*InclusionListEntry InclusionListSummary []*InclusionListEntry `rlp:"optional"`
} }
// NewBlock creates a new block. The input data is copied, changes to header and to the // NewBlock creates a new block. The input data is copied, changes to header and to the

View file

@ -0,0 +1,25 @@
// Code generated by rlpgen. DO NOT EDIT.
package types
import "github.com/ethereum/go-ethereum/rlp"
import "io"
func (obj *InclusionList) EncodeRLP(_w io.Writer) error {
w := rlp.NewEncoderBuffer(_w)
_tmp0 := w.List()
_tmp1 := w.List()
for _, _tmp2 := range obj.List {
if _tmp2 == nil {
w.Write([]byte{0xC0})
} else {
_tmp3 := w.List()
w.WriteBytes(_tmp2.Address[:])
w.WriteUint64(_tmp2.Nonce)
w.ListEnd(_tmp3)
}
}
w.ListEnd(_tmp1)
w.ListEnd(_tmp0)
return w.Flush()
}

View file

@ -0,0 +1,32 @@
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package types
import (
"encoding/json"
)
// MarshalJSON marshals as JSON.
func (i InclusionList) MarshalJSON() ([]byte, error) {
type InclusionList struct {
List []*InclusionListEntry
}
var enc InclusionList
enc.List = i.List
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (i *InclusionList) UnmarshalJSON(input []byte) error {
type InclusionList struct {
List []*InclusionListEntry
}
var dec InclusionList
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.List != nil {
i.List = dec.List
}
return nil
}

View file

@ -23,8 +23,8 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
) )
//go:generate go run github.com/fjl/gencodec -type InclusionList gen_inclusion_rlp.go //go:generate go run github.com/fjl/gencodec -type InclusionList -out gen_inclusion_rlp.go
//go:generate go run ../../rlp/rlpgen -type InclusionList -out gen_inculsion.go //go:generate go run ../../rlp/rlpgen -type InclusionList -out gen_inclusion.go
type InclusionListEntry struct { type InclusionListEntry struct {
Address common.Address Address common.Address