Skip to content

Commit

Permalink
fix: fix transaction hash nil pointer error
Browse files Browse the repository at this point in the history
This commit ensures 'invalid memory address or nil pointer dereference'
is not thrown when trying to retrieve the transaction hash inside the
rewardservice.
  • Loading branch information
rickstaa committed Dec 18, 2023
1 parent 08b00ba commit 923375c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions eth/rewardservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eth
import (
"context"
"fmt"
"strings"
"sync"

"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -59,8 +60,8 @@ func (s *RewardService) Start(ctx context.Context) error {
if err != nil {
glog.Errorf("Error trying to call reward err=%q", err)
var txHash string
if tx != nil {
txHash = tx.Hash().String()
if tx != nil && !strings.Contains(err.Error(), "context deadline exceeded") {
txHash = tx.Hash().Hex()
}

Check warning on line 65 in eth/rewardservice.go

View check run for this annotation

Codecov / codecov/patch

eth/rewardservice.go#L64-L65

Added lines #L64 - L65 were not covered by tests
if monitor.Enabled {
monitor.RewardCallError(ctx, err.Error(), s.tw.LastInitializedRound(), txHash)
Expand Down

0 comments on commit 923375c

Please sign in to comment.