From 56546a38adf4a06b51cbbd8272ccba5eabef30d1 Mon Sep 17 00:00:00 2001 From: KosukeTaniguchi Date: Wed, 15 Jun 2022 22:23:44 +0900 Subject: [PATCH 1/3] [fix]Add comment to explain returning nil instead of err --- internal/ethapi/api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 4aa37a8dc4c3..0e8409bbe2c1 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1581,6 +1581,8 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) { tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash) if err != nil { + // return nil on purpose + // When the transaction doesn't exist, the return value of this RPC call should be JSON null. return nil, nil } receipts, err := s.b.GetReceipts(ctx, blockHash) From 977ff089afee19efafdd9353e7be964f787fc8e4 Mon Sep 17 00:00:00 2001 From: KosukeTaniguchi Date: Wed, 15 Jun 2022 23:00:24 +0900 Subject: [PATCH 2/3] fix comment --- internal/ethapi/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 0e8409bbe2c1..9fcf96716a32 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1581,7 +1581,7 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) { tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash) if err != nil { - // return nil on purpose + // Returns nil on purpose instead of err // When the transaction doesn't exist, the return value of this RPC call should be JSON null. return nil, nil } From 60fd90ac8a7bda29434a6cf3ab1e538fd05593b5 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 16 Jun 2022 17:07:42 +0200 Subject: [PATCH 3/3] Update api.go --- internal/ethapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9fcf96716a32..24d9b58567b9 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1581,8 +1581,8 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) { tx, blockHash, blockNumber, index, err := s.b.GetTransaction(ctx, hash) if err != nil { - // Returns nil on purpose instead of err - // When the transaction doesn't exist, the return value of this RPC call should be JSON null. + // When the transaction doesn't exist, the RPC method should return JSON null + // as per specification. return nil, nil } receipts, err := s.b.GetReceipts(ctx, blockHash)