diff options
author | Felix Lange <fjl@twurst.com> | 2015-12-15 00:38:10 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-12-15 00:38:10 +0800 |
commit | fa187a366dda1894179635eeec2a929bfacc4ad3 (patch) | |
tree | 4494d4dcded47dd49f2fe7374e85fefa9249246e /core | |
parent | 787d71d6595df98586c625e82f4decb034215203 (diff) | |
parent | eae81465c1c815c317cd30e4de6bdf4d59df2340 (diff) | |
download | go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar.gz go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar.bz2 go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar.lz go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar.xz go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.tar.zst go-tangerine-fa187a366dda1894179635eeec2a929bfacc4ad3.zip |
Merge pull request #2035 from bas-vk/rcp-v2-rebase
rpc: new RPC implementation with pub/sub support
Diffstat (limited to 'core')
-rw-r--r-- | core/types/block.go | 4 | ||||
-rw-r--r-- | core/types/bloom9.go | 4 | ||||
-rw-r--r-- | core/vm/log.go | 16 |
3 files changed, 24 insertions, 0 deletions
diff --git a/core/types/block.go b/core/types/block.go index 1d1cfa515..5536e0ea8 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -48,6 +48,10 @@ func (n BlockNonce) Uint64() uint64 { return binary.BigEndian.Uint64(n[:]) } +func (n BlockNonce) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"0x%x"`, n)), nil +} + type Header struct { ParentHash common.Hash // Hash to the previous block UncleHash common.Hash // Uncles of this block diff --git a/core/types/bloom9.go b/core/types/bloom9.go index cd90fd971..372045ab2 100644 --- a/core/types/bloom9.go +++ b/core/types/bloom9.go @@ -69,6 +69,10 @@ func (b Bloom) TestBytes(test []byte) bool { return b.Test(common.BytesToBig(test)) } +func (b Bloom) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%#x"`, b.Bytes())), nil +} + func CreateBloom(receipts Receipts) Bloom { bin := new(big.Int) for _, receipt := range receipts { diff --git a/core/vm/log.go b/core/vm/log.go index 191e3a253..e4cc6021b 100644 --- a/core/vm/log.go +++ b/core/vm/log.go @@ -17,6 +17,7 @@ package vm import ( + "encoding/json" "fmt" "io" @@ -63,6 +64,21 @@ func (l *Log) String() string { return fmt.Sprintf(`log: %x %x %x %x %d %x %d`, l.Address, l.Topics, l.Data, l.TxHash, l.TxIndex, l.BlockHash, l.Index) } +func (r *Log) MarshalJSON() ([]byte, error) { + fields := map[string]interface{}{ + "address": r.Address, + "data": fmt.Sprintf("%#x", r.Data), + "blockNumber": fmt.Sprintf("%#x", r.BlockNumber), + "logIndex": fmt.Sprintf("%#x", r.Index), + "blockHash": r.BlockHash, + "transactionHash": r.TxHash, + "transactionIndex": fmt.Sprintf("%#x", r.TxIndex), + "topics": r.Topics, + } + + return json.Marshal(fields) +} + type Logs []*Log // LogForStorage is a wrapper around a Log that flattens and parses the entire |