diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-20 17:26:32 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 429d5cb30e0883b5f2e68fb7a3b38c80836df5f5 (patch) | |
tree | 23ce8392e9fd81987d2bf4eda50a1e1a100f8002 | |
parent | 9f56debcde5617d7bf13288b9bebca763e4fe234 (diff) | |
download | dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar.gz dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar.bz2 dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar.lz dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar.xz dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.tar.zst dexon-429d5cb30e0883b5f2e68fb7a3b38c80836df5f5.zip |
core: included Dexcon metadata in block
-rw-r--r-- | core/types/block.go | 5 | ||||
-rw-r--r-- | dex/app.go | 16 | ||||
-rw-r--r-- | internal/ethapi/api.go | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/core/types/block.go b/core/types/block.go index 069221b82..e8e15d332 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -88,8 +88,9 @@ type Header struct { Randomness []byte `json:"randomness" gencodec:"required"` Position coreTypes.Position `json:"position" gencodec:"required"` WitnessHeight uint64 `json:"witnessHeight" gencodec:"required"` - WitnessRoot common.Hash `json:"WitnessRoot" gencodec:"required"` - WitnessReceiptHash common.Hash `json:"WitnessReceiptHash" gencodec:"required"` + WitnessRoot common.Hash `json:"witnessRoot" gencodec:"required"` + WitnessReceiptHash common.Hash `json:"witnessReceiptHash" gencodec:"required"` + DexconMeta []byte `json:"dexconMeta" gencodec:"required"` ChainID uint32 `json:"chainID" gencodec:"required"` ChainBlockHeight uint64 `json:"chainBlockHeight" gencodec:"required"` } diff --git a/dex/app.go b/dex/app.go index 40366c25f..ecd29546e 100644 --- a/dex/app.go +++ b/dex/app.go @@ -347,22 +347,27 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F block := d.blockchain.GetConfirmedBlockByHash(blockHash) if block == nil { - log.Error("Can not get confirmed block") - return + panic("Can not get confirmed block") } var transactions types.Transactions err := rlp.Decode(bytes.NewReader(block.Payload), &transactions) if err != nil { log.Error("Payload rlp decode failed", "error", err) - return + panic(err) } var witnessData witnessData err = rlp.Decode(bytes.NewReader(block.Witness.Data), &witnessData) if err != nil { log.Error("Witness rlp decode failed", "error", err) - return + panic(err) + } + + block.Payload = nil + dexconMeta, err := rlp.EncodeToBytes(block) + if err != nil { + panic(err) } log.Debug("Block proposer id", "hash", block.ProposerID) @@ -378,13 +383,14 @@ func (d *DexconApp) BlockDelivered(blockHash coreCommon.Hash, result coreTypes.F ChainBlockHeight: block.Position.Height, // TODO(bojie): fix it GasLimit: 8000000, + DexconMeta: dexconMeta, Difficulty: big.NewInt(1), }, transactions, nil, nil) _, err = d.blockchain.InsertPendingBlocks([]*types.Block{newBlock}) if err != nil { log.Error("Insert chain", "error", err) - return + panic(err) } log.Debug("Insert pending block success", "height", result.Height) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 1badba230..557e0eb3c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -885,6 +885,8 @@ func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool) (map[string]inter "timestamp": (*hexutil.Big)(head.Time), "transactionsRoot": head.TxHash, "receiptsRoot": head.ReceiptHash, + "randomness": hexutil.Bytes(head.Randomness), + "dexconMeta": hexutil.Bytes(head.DexconMeta), } if inclTx { |