mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
all: add Codeword to header
This commit is contained in:
parent
2b9f9285d2
commit
19d8abb4d6
3 changed files with 23 additions and 2 deletions
|
|
@ -1180,6 +1180,14 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
|
||||||
result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
|
result["baseFeePerGas"] = (*hexutil.Big)(head.BaseFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if head.Codeword != nil {
|
||||||
|
result["codeword"] = hexutil.Bytes(head.Codeword)
|
||||||
|
}
|
||||||
|
|
||||||
|
if head.CodeLength != 0 {
|
||||||
|
result["codelength"] = hexutil.Uint64(head.CodeLength)
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,8 @@ type btHeader struct {
|
||||||
GasUsed uint64
|
GasUsed uint64
|
||||||
Timestamp uint64
|
Timestamp uint64
|
||||||
BaseFeePerGas *big.Int
|
BaseFeePerGas *big.Int
|
||||||
|
Codeword []byte
|
||||||
|
CodeLength uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type btHeaderMarshaling struct {
|
type btHeaderMarshaling struct {
|
||||||
|
|
@ -175,8 +177,7 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II
|
||||||
See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II
|
|
||||||
|
|
||||||
Whether a block is valid or not is a bit subtle, it's defined by presence of
|
Whether a block is valid or not is a bit subtle, it's defined by presence of
|
||||||
blockHeader, transactions and uncleHeaders fields. If they are missing, the block is
|
blockHeader, transactions and uncleHeaders fields. If they are missing, the block is
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
|
||||||
GasUsed math.HexOrDecimal64
|
GasUsed math.HexOrDecimal64
|
||||||
Timestamp math.HexOrDecimal64
|
Timestamp math.HexOrDecimal64
|
||||||
BaseFeePerGas *math.HexOrDecimal256
|
BaseFeePerGas *math.HexOrDecimal256
|
||||||
|
Codeword hexutil.Bytes
|
||||||
|
CodeLength math.HexOrDecimal64
|
||||||
}
|
}
|
||||||
var enc btHeader
|
var enc btHeader
|
||||||
enc.Bloom = b.Bloom
|
enc.Bloom = b.Bloom
|
||||||
|
|
@ -48,6 +50,8 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
|
||||||
enc.TransactionsTrie = b.TransactionsTrie
|
enc.TransactionsTrie = b.TransactionsTrie
|
||||||
enc.UncleHash = b.UncleHash
|
enc.UncleHash = b.UncleHash
|
||||||
enc.ExtraData = b.ExtraData
|
enc.ExtraData = b.ExtraData
|
||||||
|
enc.Codeword = b.Codeword
|
||||||
|
enc.CodeLength = math.HexOrDecimal64(b.GasLimit)
|
||||||
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
|
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
|
||||||
enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
|
enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
|
||||||
enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
|
enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
|
||||||
|
|
@ -76,6 +80,8 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
|
||||||
GasUsed *math.HexOrDecimal64
|
GasUsed *math.HexOrDecimal64
|
||||||
Timestamp *math.HexOrDecimal64
|
Timestamp *math.HexOrDecimal64
|
||||||
BaseFeePerGas *math.HexOrDecimal256
|
BaseFeePerGas *math.HexOrDecimal256
|
||||||
|
Codeword *hexutil.Bytes
|
||||||
|
CodeLength *math.HexOrDecimal64
|
||||||
}
|
}
|
||||||
var dec btHeader
|
var dec btHeader
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
@ -117,6 +123,12 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
|
||||||
if dec.ExtraData != nil {
|
if dec.ExtraData != nil {
|
||||||
b.ExtraData = *dec.ExtraData
|
b.ExtraData = *dec.ExtraData
|
||||||
}
|
}
|
||||||
|
if dec.Codeword != nil {
|
||||||
|
b.Codeword = *dec.Codeword
|
||||||
|
}
|
||||||
|
if dec.CodeLength != nil {
|
||||||
|
b.CodeLength = uint64(*dec.CodeLength)
|
||||||
|
}
|
||||||
if dec.Difficulty != nil {
|
if dec.Difficulty != nil {
|
||||||
b.Difficulty = (*big.Int)(dec.Difficulty)
|
b.Difficulty = (*big.Int)(dec.Difficulty)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue