Skip to content

Commit a31835c

Browse files
rjl493456442karalabe
authored andcommitted
internal/ethapi: add status code to receipt rpc return
1 parent d78ad22 commit a31835c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/ethapi/api.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ import (
4444
)
4545

4646
const (
47-
defaultGas = 90000
48-
defaultGasPrice = 50 * params.Shannon
47+
defaultGas = 90000
48+
defaultGasPrice = 50 * params.Shannon
49+
receiptStatusSuccessful = 1
50+
receiptStatusFailed = 0
4951
)
5052

5153
// PublicEthereumAPI provides an API to access Ethereum related information.
@@ -991,7 +993,6 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[
991993
from, _ := types.Sender(signer, tx)
992994

993995
fields := map[string]interface{}{
994-
"root": hexutil.Bytes(receipt.PostState),
995996
"blockHash": blockHash,
996997
"blockNumber": hexutil.Uint64(blockNumber),
997998
"transactionHash": hash,
@@ -1004,6 +1005,16 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[
10041005
"logs": receipt.Logs,
10051006
"logsBloom": receipt.Bloom,
10061007
}
1008+
1009+
// Assign receipt status or post state.
1010+
if len(receipt.PostState) > 0 {
1011+
fields["root"] = hexutil.Bytes(receipt.PostState)
1012+
} else {
1013+
fields["status"] = hexutil.Uint(receiptStatusSuccessful)
1014+
if receipt.Failed {
1015+
fields["status"] = hexutil.Uint(receiptStatusFailed)
1016+
}
1017+
}
10071018
if receipt.Logs == nil {
10081019
fields["logs"] = [][]*types.Log{}
10091020
}

0 commit comments

Comments
 (0)