From aafd64dd82c13aa15c06a5f25740f0fd333ea0de Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 5 Apr 2017 14:04:24 +0200 Subject: [PATCH] core/types: add "hash" to JSON headers --- core/types/block.go | 1 + core/types/gen_header_json.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core/types/block.go b/core/types/block.go index dcb5ca3be1..8ca3d0e896 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -93,6 +93,7 @@ type headerMarshaling struct { GasUsed *hexutil.Big Time *hexutil.Big Extra hexutil.Bytes + Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON } // Hash returns the block hash of the header, which is simply the keccak256 hash of its diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index c18271d539..bcff7a940d 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -28,6 +28,7 @@ func (h Header) MarshalJSON() ([]byte, error) { Extra hexutil.Bytes `json:"extraData" gencodec:"required"` MixDigest common.Hash `json:"mixHash" gencodec:"required"` Nonce BlockNonce `json:"nonce" gencodec:"required"` + Hash common.Hash `json:"hash"` } var enc Header enc.ParentHash = h.ParentHash @@ -45,6 +46,7 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.Extra = h.Extra enc.MixDigest = h.MixDigest enc.Nonce = h.Nonce + enc.Hash = h.Hash() return json.Marshal(&enc) }