aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--consensus/dexcon/dexcon.go2
-rw-r--r--core/types/block.go43
-rw-r--r--core/types/gen_header_json.go22
-rw-r--r--internal/ethapi/api.go2
4 files changed, 30 insertions, 39 deletions
diff --git a/consensus/dexcon/dexcon.go b/consensus/dexcon/dexcon.go
index 67bf33bbf..f0a133ccf 100644
--- a/consensus/dexcon/dexcon.go
+++ b/consensus/dexcon/dexcon.go
@@ -114,7 +114,7 @@ func (d *Dexcon) Finalize(chain consensus.ChainReader, header *types.Header, sta
reward := new(big.Int).Div(config.BlockReward, big.NewInt(int64(config.NumChains)))
state.AddBalance(header.Coinbase, reward)
- header.BlockReward = reward
+ header.Reward = reward
header.Root = state.IntermediateRoot(true)
return types.NewBlock(header, txs, uncles, receipts), nil
}
diff --git a/core/types/block.go b/core/types/block.go
index 07fc55358..6186c66bb 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -26,7 +26,6 @@ import (
"time"
"unsafe"
- coreTypes "github.com/dexon-foundation/dexon-consensus/core/types"
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/common/hexutil"
"github.com/dexon-foundation/dexon/rlp"
@@ -75,26 +74,25 @@ type WitnessData struct {
// Header represents a block header in the Ethereum blockchain.
type Header 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 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 BlockNonce `json:"nonce"`
- Randomness []byte `json:"randomness" gencodec:"required"`
- Position coreTypes.Position `json:"position" gencodec:"required"`
- Round uint64 `json:"round" gencodec:"required"`
- DexconMeta []byte `json:"dexconMeta" gencodec:"required"`
- BlockReward *big.Int `json:"blockReward" gencodec:"required"`
+ 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 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 BlockNonce `json:"nonce"`
+ Reward *big.Int `json:"reward" gencodec:"required"`
+ Randomness []byte `json:"randomness" gencodec:"required"`
+ Round uint64 `json:"round" gencodec:"required"`
+ DexconMeta []byte `json:"dexconMeta" gencodec:"required"`
}
// field type overrides for gencodec
@@ -105,9 +103,10 @@ type headerMarshaling struct {
GasUsed hexutil.Uint64
Time hexutil.Uint64
Extra hexutil.Bytes
- Randomness hexutil.Bytes
Round hexutil.Uint64
+ Randomness hexutil.Bytes
DexconMeta hexutil.Bytes
+ Reward *hexutil.Big
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
}
diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go
index b49d48f14..5b14ab26e 100644
--- a/core/types/gen_header_json.go
+++ b/core/types/gen_header_json.go
@@ -7,7 +7,6 @@ import (
"errors"
"math/big"
- "github.com/dexon-foundation/dexon-consensus/core/types"
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/common/hexutil"
)
@@ -32,11 +31,10 @@ func (h Header) MarshalJSON() ([]byte, error) {
Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"`
Nonce BlockNonce `json:"nonce"`
+ Reward *hexutil.Big `json:"reward" gencodec:"required"`
Randomness hexutil.Bytes `json:"randomness" gencodec:"required"`
- Position types.Position `json:"position" gencodec:"required"`
Round hexutil.Uint64 `json:"round" gencodec:"required"`
DexconMeta hexutil.Bytes `json:"dexconMeta" gencodec:"required"`
- BlockReward *big.Int `json:"blockReward" gencodec:"required"`
Hash common.Hash `json:"hash"`
}
var enc Header
@@ -55,11 +53,10 @@ func (h Header) MarshalJSON() ([]byte, error) {
enc.Extra = h.Extra
enc.MixDigest = h.MixDigest
enc.Nonce = h.Nonce
+ enc.Reward = (*hexutil.Big)(h.Reward)
enc.Randomness = h.Randomness
- enc.Position = h.Position
enc.Round = hexutil.Uint64(h.Round)
enc.DexconMeta = h.DexconMeta
- enc.BlockReward = h.BlockReward
enc.Hash = h.Hash()
return json.Marshal(&enc)
}
@@ -82,11 +79,10 @@ func (h *Header) UnmarshalJSON(input []byte) error {
Extra *hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest *common.Hash `json:"mixHash"`
Nonce *BlockNonce `json:"nonce"`
+ Reward *hexutil.Big `json:"reward" gencodec:"required"`
Randomness *hexutil.Bytes `json:"randomness" gencodec:"required"`
- Position *types.Position `json:"position" gencodec:"required"`
Round *hexutil.Uint64 `json:"round" gencodec:"required"`
DexconMeta *hexutil.Bytes `json:"dexconMeta" gencodec:"required"`
- BlockReward *big.Int `json:"blockReward" gencodec:"required"`
}
var dec Header
if err := json.Unmarshal(input, &dec); err != nil {
@@ -150,14 +146,14 @@ func (h *Header) UnmarshalJSON(input []byte) error {
if dec.Nonce != nil {
h.Nonce = *dec.Nonce
}
+ if dec.Reward == nil {
+ return errors.New("missing required field 'reward' for Header")
+ }
+ h.Reward = (*big.Int)(dec.Reward)
if dec.Randomness == nil {
return errors.New("missing required field 'randomness' for Header")
}
h.Randomness = *dec.Randomness
- if dec.Position == nil {
- return errors.New("missing required field 'position' for Header")
- }
- h.Position = *dec.Position
if dec.Round == nil {
return errors.New("missing required field 'round' for Header")
}
@@ -166,9 +162,5 @@ func (h *Header) UnmarshalJSON(input []byte) error {
return errors.New("missing required field 'dexconMeta' for Header")
}
h.DexconMeta = *dec.DexconMeta
- if dec.BlockReward == nil {
- return errors.New("missing required field 'blockReward' for Header")
- }
- h.BlockReward = dec.BlockReward
return nil
}
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 93906f35f..8c950d5cf 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -894,10 +894,10 @@ func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]inter
"timestamp": hexutil.Uint64(head.Time),
"transactionsRoot": head.TxHash,
"receiptsRoot": head.ReceiptHash,
+ "reward": (*hexutil.Big)(head.Reward),
"randomness": hexutil.Bytes(head.Randomness),
"round": hexutil.Uint64(head.Round),
"dexconMeta": hexutil.Bytes(head.DexconMeta),
- "blockReward": (*hexutil.Big)(head.BlockReward),
}
if inclTx {