mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
change method and handle case with no reward
This commit is contained in:
parent
8ca51b6ee4
commit
576bdfff79
1 changed files with 5 additions and 3 deletions
|
|
@ -389,7 +389,9 @@ func (api *API) GetRewardByAccount(account common.Address, begin rpc.BlockNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, reward := range epochRewards {
|
for _, reward := range epochRewards {
|
||||||
|
if reward.AccountReward != nil {
|
||||||
total.TotalAccountReward = new(big.Int).Add(total.TotalAccountReward, reward.AccountReward)
|
total.TotalAccountReward = new(big.Int).Add(total.TotalAccountReward, reward.AccountReward)
|
||||||
|
}
|
||||||
for k, v := range reward.DelegatedReward {
|
for k, v := range reward.DelegatedReward {
|
||||||
_, exist := total.TotalDelegatedReward[k]
|
_, exist := total.TotalDelegatedReward[k]
|
||||||
if exist {
|
if exist {
|
||||||
|
|
@ -441,7 +443,7 @@ func (api *API) getRewardFileNamesInRange(begin, end *rpc.BlockNumber) ([]reward
|
||||||
log.Warn("[getEpochNumbersFromRewardFiles] found unknown filename format in rewards folder")
|
log.Warn("[getEpochNumbersFromRewardFiles] found unknown filename format in rewards folder")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fileSuffixHash := common.StringToHash(fileSuffix)
|
fileSuffixHash := common.HexToHash(fileSuffix)
|
||||||
rewardName := rewardFileName{
|
rewardName := rewardFileName{
|
||||||
epochBlockNum: filePrefixInt,
|
epochBlockNum: filePrefixInt,
|
||||||
epochBlockHash: fileSuffixHash,
|
epochBlockHash: fileSuffixHash,
|
||||||
|
|
@ -464,7 +466,7 @@ func (api *API) getRewardFileNamesInRange(begin, end *rpc.BlockNumber) ([]reward
|
||||||
endIndex := sort.SearchInts(epochNumbers, int(endHeader.Number.Int64()))
|
endIndex := sort.SearchInts(epochNumbers, int(endHeader.Number.Int64()))
|
||||||
|
|
||||||
var rewardfileNamesInRange []rewardFileName
|
var rewardfileNamesInRange []rewardFileName
|
||||||
for i:= startIndex; i<= endIndex; i++{
|
for i := startIndex; i <= endIndex; i++ {
|
||||||
rewardfileNamesInRange = append(rewardfileNamesInRange, rewardFileNames[i])
|
rewardfileNamesInRange = append(rewardfileNamesInRange, rewardFileNames[i])
|
||||||
}
|
}
|
||||||
return rewardfileNamesInRange, nil
|
return rewardfileNamesInRange, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue