aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-08-17 23:14:42 +0800
committerGitHub <noreply@github.com>2016-08-17 23:14:42 +0800
commit3369783e0a3e0c06388cf59fddfd799811381a2b (patch)
treecb29e4550f63f3a763dd04b267261e354e56d7eb /core
parent3b39d4d1c15df2697284c3d7a61564f98ab45c70 (diff)
parent47ff8130124b479f1f051312eed50c33f0a38e6f (diff)
downloaddexon-3369783e0a3e0c06388cf59fddfd799811381a2b.tar.gz
dexon-3369783e0a3e0c06388cf59fddfd799811381a2b.tar.zst
dexon-3369783e0a3e0c06388cf59fddfd799811381a2b.zip
Merge pull request #2885 from bas-vk/subscriptions
rpc: refactor subscriptions and filters
Diffstat (limited to 'core')
-rw-r--r--core/types/block.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 37b6f3ec1..599359247 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -114,6 +114,28 @@ func (h *Header) UnmarshalJSON(data []byte) error {
return nil
}
+func (h *Header) MarshalJSON() ([]byte, error) {
+ fields := map[string]interface{}{
+ "hash": h.Hash(),
+ "parentHash": h.ParentHash,
+ "number": fmt.Sprintf("%#x", h.Number),
+ "nonce": h.Nonce,
+ "receiptRoot": h.ReceiptHash,
+ "logsBloom": h.Bloom,
+ "sha3Uncles": h.UncleHash,
+ "stateRoot": h.Root,
+ "miner": h.Coinbase,
+ "difficulty": fmt.Sprintf("%#x", h.Difficulty),
+ "extraData": fmt.Sprintf("0x%x", h.Extra),
+ "gasLimit": fmt.Sprintf("%#x", h.GasLimit),
+ "gasUsed": fmt.Sprintf("%#x", h.GasUsed),
+ "timestamp": fmt.Sprintf("%#x", h.Time),
+ "transactionsRoot": h.TxHash,
+ }
+
+ return json.Marshal(fields)
+}
+
func rlpHash(x interface{}) (h common.Hash) {
hw := sha3.NewKeccak256()
rlp.Encode(hw, x)