Skip to content

Commit

Permalink
internal/ethapi: add status code to receipt rpc return
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 authored and karalabe committed Oct 2, 2017
1 parent d78ad22 commit a31835c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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{}
}
Expand Down

0 comments on commit a31835c

Please sign in to comment.