From a31835c8b4086582879a4e7a48e4bdb5e4dccc3d Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Sat, 26 Aug 2017 15:30:56 +0800 Subject: internal/ethapi: add status code to receipt rpc return --- internal/ethapi/api.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8d1a6f746..a7cb08466 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -44,8 +44,10 @@ import ( ) const ( - defaultGas = 90000 - defaultGasPrice = 50 * params.Shannon + defaultGas = 90000 + defaultGasPrice = 50 * params.Shannon + receiptStatusSuccessful = 1 + receiptStatusFailed = 0 ) // PublicEthereumAPI provides an API to access Ethereum related information. @@ -991,7 +993,6 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[ from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ - "root": hexutil.Bytes(receipt.PostState), "blockHash": blockHash, "blockNumber": hexutil.Uint64(blockNumber), "transactionHash": hash, @@ -1004,6 +1005,16 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[ "logs": receipt.Logs, "logsBloom": receipt.Bloom, } + + // Assign receipt status or post state. + if len(receipt.PostState) > 0 { + fields["root"] = hexutil.Bytes(receipt.PostState) + } else { + fields["status"] = hexutil.Uint(receiptStatusSuccessful) + if receipt.Failed { + fields["status"] = hexutil.Uint(receiptStatusFailed) + } + } if receipt.Logs == nil { fields["logs"] = [][]*types.Log{} } -- cgit From 7e9e3a134b9607209def42279db081973b5e0ac2 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Mon, 2 Oct 2017 11:42:08 +0300 Subject: core/types, internal: swap Receipt.Failed to Status --- internal/ethapi/api.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'internal') diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index a7cb08466..ab8478929 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -44,10 +44,8 @@ import ( ) const ( - defaultGas = 90000 - defaultGasPrice = 50 * params.Shannon - receiptStatusSuccessful = 1 - receiptStatusFailed = 0 + defaultGas = 90000 + defaultGasPrice = 50 * params.Shannon ) // PublicEthereumAPI provides an API to access Ethereum related information. @@ -1010,10 +1008,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[ if len(receipt.PostState) > 0 { fields["root"] = hexutil.Bytes(receipt.PostState) } else { - fields["status"] = hexutil.Uint(receiptStatusSuccessful) - if receipt.Failed { - fields["status"] = hexutil.Uint(receiptStatusFailed) - } + fields["status"] = hexutil.Uint(receipt.Status) } if receipt.Logs == nil { fields["logs"] = [][]*types.Log{} -- cgit