core/types: add "hash" to JSON headers

This commit is contained in:
Felix Lange 2017-04-05 14:04:24 +02:00
parent 260343ccbb
commit aafd64dd82
2 changed files with 3 additions and 0 deletions

View file

@ -93,6 +93,7 @@ type headerMarshaling struct {
GasUsed *hexutil.Big GasUsed *hexutil.Big
Time *hexutil.Big Time *hexutil.Big
Extra hexutil.Bytes 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 // Hash returns the block hash of the header, which is simply the keccak256 hash of its

View file

@ -28,6 +28,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
Extra hexutil.Bytes `json:"extraData" gencodec:"required"` Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash" gencodec:"required"` MixDigest common.Hash `json:"mixHash" gencodec:"required"`
Nonce BlockNonce `json:"nonce" gencodec:"required"` Nonce BlockNonce `json:"nonce" gencodec:"required"`
Hash common.Hash `json:"hash"`
} }
var enc Header var enc Header
enc.ParentHash = h.ParentHash enc.ParentHash = h.ParentHash
@ -45,6 +46,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
enc.Extra = h.Extra enc.Extra = h.Extra
enc.MixDigest = h.MixDigest enc.MixDigest = h.MixDigest
enc.Nonce = h.Nonce enc.Nonce = h.Nonce
enc.Hash = h.Hash()
return json.Marshal(&enc) return json.Marshal(&enc)
} }