mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
core/types: add inclusion list types
This commit is contained in:
parent
226fe5c203
commit
f27bd687b9
4 changed files with 63 additions and 6 deletions
|
|
@ -173,8 +173,8 @@ func (h *Header) EmptyReceipts() bool {
|
||||||
type Body struct {
|
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.
|
||||||
|
|
@ -216,8 +216,8 @@ type extblock struct {
|
||||||
Header *Header
|
Header *Header
|
||||||
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
|
||||||
|
|
|
||||||
25
core/types/gen_inclusion.go
Normal file
25
core/types/gen_inclusion.go
Normal 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()
|
||||||
|
}
|
||||||
32
core/types/gen_inclusion_rlp.go
Normal file
32
core/types/gen_inclusion_rlp.go
Normal 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
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue