-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP fix eth_getRewardByHash by enabling storereward #745
Conversation
eth/api_backend.go
Outdated
if err == nil { | ||
rewards := make(map[string]map[string]map[string]*big.Int) | ||
err = json.Unmarshal(data, &rewards) | ||
if err == nil { | ||
log.Error("[GetRewardByHash] file found and returning rewards", "blocknum", header.Number.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why log an error when err == nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, thanks!
578f856
to
e94316f
Compare
The function |
@@ -408,25 +408,19 @@ func (b *EthApiBackend) StateAtBlock(ctx context.Context, block *types.Block, re | |||
|
|||
func (s *EthApiBackend) GetRewardByHash(hash common.Hash) map[string]map[string]map[string]*big.Int { | |||
header := s.eth.blockchain.GetHeaderByHash(hash) | |||
err := errors.New("header hash not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is useless sometimes, such as when return rewards
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relocate this error declaration and put a missing hash into the message, so that whenever it logs, we know which hash is missing
} | ||
} | ||
log.Error("[GetRewardByHash]", "err", err) | ||
return make(map[string]map[string]map[string]*big.Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we return nil
and err if err != nil
? So API caller know the fail reason.
this change is not required anymore |
Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅
in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅
in the boxes that applyAPI
Checklist
Put an
✅
in the boxes once you have confirmed below actions (or provide reasons on not doing so) that