diff --git a/handlers/mempoolView.go b/handlers/mempoolView.go index cf9986ae2b..4b431de008 100644 --- a/handlers/mempoolView.go +++ b/handlers/mempoolView.go @@ -65,7 +65,7 @@ func toTableDataRow(tx *types.RawMempoolTransaction) []interface{} { utils.FormatAddressAll(tx.From.Bytes(), "", false, "address", "", int(12), int(12), true), _isContractCreation(tx.To), utils.FormatAmount((*big.Int)(tx.Value), utils.Config.Frontend.ElCurrency, 5), - utils.FormatAddCommasFormated(float64(tx.Gas.ToInt().Int64()), 0), + utils.FormatAddCommasFormatted(float64(tx.Gas.ToInt().Int64()), 0), utils.FormatAmountFormatted(tx.GasPrice.ToInt(), "GWei", 5, 0, true, true, false), tx.Nonce.ToInt(), } diff --git a/handlers/validator.go b/handlers/validator.go index 0dfc3849ee..fa8a46fa31 100644 --- a/handlers/validator.go +++ b/handlers/validator.go @@ -1592,8 +1592,8 @@ func ValidatorHistory(w http.ResponseWriter, r *http.Request) { maxPages := 10 vars := mux.Vars(r) - index, err := strconv.ParseUint(vars["index"], 10, 64) - if err != nil || index > math.MaxInt32 { // index in postgres is limited to int + index, err := strconv.ParseUint(vars["index"], 10, 31) + if err != nil { logger.Warnf("error parsing validator index: %v", err) http.Error(w, "Error: Invalid parameter validator index.", http.StatusBadRequest) return @@ -1709,7 +1709,7 @@ func ValidatorHistory(w http.ResponseWriter, r *http.Request) { } else if len(tableData) >= pageLength { continue } - tableData = append(tableData, icomeToTableData(i, incomeDetails[index][i], withdrawalMap[i], currency)) + tableData = append(tableData, incomeToTableData(i, incomeDetails[index][i], withdrawalMap[i], currency)) } } @@ -1750,7 +1750,7 @@ func ValidatorHistory(w http.ResponseWriter, r *http.Request) { } continue } - tableData = append(tableData, icomeToTableData(epoch, incomeDetails[index][epoch], withdrawalMap[epoch], currency)) + tableData = append(tableData, incomeToTableData(epoch, incomeDetails[index][epoch], withdrawalMap[epoch], currency)) } } @@ -1821,7 +1821,7 @@ func getWithdrawalAndIncome(index uint64, startEpoch uint64, endEpoch uint64) (m return withdrawalMap, incomeDetails, err } -func icomeToTableData(epoch uint64, income *itypes.ValidatorEpochIncome, withdrawal *types.ValidatorWithdrawal, currency string) []interface{} { +func incomeToTableData(epoch uint64, income *itypes.ValidatorEpochIncome, withdrawal *types.ValidatorWithdrawal, currency string) []interface{} { events := template.HTML("") if income.AttestationSourcePenalty > 0 && income.AttestationTargetPenalty > 0 { events += utils.FormatAttestationStatusShort(2) @@ -1845,7 +1845,7 @@ func icomeToTableData(epoch uint64, income *itypes.ValidatorEpochIncome, withdra rewards := income.TotalClRewards() return []interface{}{ utils.FormatEpoch(epoch), - utils.FormatBalanceChangeFormated(&rewards, currency, income), + utils.FormatBalanceChangeFormatted(&rewards, currency, income), template.HTML(""), template.HTML(events), } diff --git a/utils/format.go b/utils/format.go index c7faae35d8..4a0ef5e924 100644 --- a/utils/format.go +++ b/utils/format.go @@ -73,13 +73,13 @@ func FormatAttestationStatus(status uint64) template.HTML { // FormatAttestationStatusShort will return a user-friendly attestation for an attestation status number func FormatAttestationStatusShort(status uint64) template.HTML { if status == 0 { - return `Sche.` + return `Sche.` } else if status == 1 { return `Att.` } else if status == 2 { - return `Miss.` + return `Miss.` } else if status == 3 { - return `Orph.` + return `Orph.` } else if status == 4 { return `Leak` } else if status == 5 { @@ -257,7 +257,7 @@ func IfToDec(valIf interface{}) decimal.Decimal { return val } -func FormatBalanceChangeFormated(balance *int64, currencyName string, details *itypes.ValidatorEpochIncome) template.HTML { +func FormatBalanceChangeFormatted(balance *int64, currencyName string, details *itypes.ValidatorEpochIncome) template.HTML { currencySymbol := "GWei" currencyFunc := ClToCurrencyGwei if currencyName != Config.Frontend.MainCurrency { @@ -273,49 +273,49 @@ func FormatBalanceChangeFormated(balance *int64, currencyName string, details *i income := "" if details != nil { - income += fmt.Sprintf("Att. Source: %s %s
", FormatAddCommasFormated(currencyFunc(details.AttestationSourceReward-details.AttestationSourcePenalty, currencyName).InexactFloat64(), maxDigits), currencySymbol) - income += fmt.Sprintf("Att. Target: %s %s
", FormatAddCommasFormated(currencyFunc(details.AttestationTargetReward-details.AttestationTargetPenalty, currencyName).InexactFloat64(), maxDigits), currencySymbol) - income += fmt.Sprintf("Att. Head Vote: %s %s
", FormatAddCommasFormated(currencyFunc(details.AttestationHeadReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Att. Source: %s %s
", FormatAddCommasFormatted(currencyFunc(IfToDec(details.AttestationSourceReward).Sub(IfToDec(details.AttestationSourcePenalty)), currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Att. Target: %s %s
", FormatAddCommasFormatted(currencyFunc(IfToDec(details.AttestationTargetReward).Sub(IfToDec(details.AttestationTargetPenalty)), currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Att. Head Vote: %s %s
", FormatAddCommasFormatted(currencyFunc(details.AttestationHeadReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) if details.FinalityDelayPenalty > 0 { - income += fmt.Sprintf("Finality Delay Penalty: %s %s
", FormatAddCommasFormated(currencyFunc(details.FinalityDelayPenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) + income += fmt.Sprintf("Finality Delay Penalty: %s %s
", FormatAddCommasFormatted(currencyFunc(details.FinalityDelayPenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) } if details.ProposerSlashingInclusionReward > 0 { - income += fmt.Sprintf("Proposer Slashing Inc. Reward: %s %s
", FormatAddCommasFormated(currencyFunc(details.ProposerSlashingInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Proposer Slashing Inc. Reward: %s %s
", FormatAddCommasFormatted(currencyFunc(details.ProposerSlashingInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) } if details.ProposerAttestationInclusionReward > 0 { - income += fmt.Sprintf("Proposer Att. Inc. Reward: %s %s
", FormatAddCommasFormated(currencyFunc(details.ProposerAttestationInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Proposer Att. Inc. Reward: %s %s
", FormatAddCommasFormatted(currencyFunc(details.ProposerAttestationInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) } if details.ProposerSyncInclusionReward > 0 { - income += fmt.Sprintf("Proposer Sync Inc. Reward: %s %s
", FormatAddCommasFormated(currencyFunc(details.ProposerSyncInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Proposer Sync Inc. Reward: %s %s
", FormatAddCommasFormatted(currencyFunc(details.ProposerSyncInclusionReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) } if details.SyncCommitteeReward > 0 { - income += fmt.Sprintf("Sync Comm. Reward: %s %s
", FormatAddCommasFormated(currencyFunc(details.SyncCommitteeReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Sync Comm. Reward: %s %s
", FormatAddCommasFormatted(currencyFunc(details.SyncCommitteeReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) } if details.SyncCommitteePenalty > 0 { - income += fmt.Sprintf("Sync Comm. Penalty: %s %s
", FormatAddCommasFormated(currencyFunc(details.SyncCommitteePenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) + income += fmt.Sprintf("Sync Comm. Penalty: %s %s
", FormatAddCommasFormatted(currencyFunc(details.SyncCommitteePenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) } if details.SlashingReward > 0 { - income += fmt.Sprintf("Slashing Reward: %s %s
", FormatAddCommasFormated(currencyFunc(details.SlashingReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Slashing Reward: %s %s
", FormatAddCommasFormatted(currencyFunc(details.SlashingReward, currencyName).InexactFloat64(), maxDigits), currencySymbol) } if details.SlashingPenalty > 0 { - income += fmt.Sprintf("Slashing Penalty: %s %s
", FormatAddCommasFormated(currencyFunc(details.SlashingPenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) + income += fmt.Sprintf("Slashing Penalty: %s %s
", FormatAddCommasFormatted(currencyFunc(details.SlashingPenalty, currencyName).InexactFloat64()*-1, maxDigits), currencySymbol) } - income += fmt.Sprintf("Total: %s %s", FormatAddCommasFormated(currencyFunc(details.TotalClRewards(), currencyName).InexactFloat64(), maxDigits), currencySymbol) + income += fmt.Sprintf("Total: %s %s", FormatAddCommasFormatted(currencyFunc(details.TotalClRewards(), currencyName).InexactFloat64(), maxDigits), currencySymbol) } if *balance < 0 { - return template.HTML(fmt.Sprintf("%s %s", income, FormatAddCommasFormated(currencyFunc(*balance, currencyName).InexactFloat64(), maxDigits), currencySymbol)) + return template.HTML(fmt.Sprintf("%s %s", income, FormatAddCommasFormatted(currencyFunc(*balance, currencyName).InexactFloat64(), maxDigits), currencySymbol)) } - return template.HTML(fmt.Sprintf("+%s %s", income, FormatAddCommasFormated(currencyFunc(*balance, currencyName).InexactFloat64(), maxDigits), currencySymbol)) + return template.HTML(fmt.Sprintf("+%s %s", income, FormatAddCommasFormatted(currencyFunc(*balance, currencyName).InexactFloat64(), maxDigits), currencySymbol)) } // FormatBalanceChange will return a string for a balance change @@ -325,9 +325,9 @@ func FormatBalanceChange(balance *int64, currency string) template.HTML { return template.HTML(" 0 " + currency + "") } if *balance < 0 { - return template.HTML(fmt.Sprintf("%s GWei", FormatAddCommasFormated(ClToCurrencyGwei(*balance, currency).InexactFloat64(), 0))) + return template.HTML(fmt.Sprintf("%s GWei", FormatAddCommasFormatted(ClToCurrencyGwei(*balance, currency).InexactFloat64(), 0))) } - return template.HTML(fmt.Sprintf("+%s GWei", FormatAddCommasFormated(ClToCurrencyGwei(*balance, currency).InexactFloat64(), 0))) + return template.HTML(fmt.Sprintf("+%s GWei", FormatAddCommasFormatted(ClToCurrencyGwei(*balance, currency).InexactFloat64(), 0))) } if balance == nil { return template.HTML(" 0 " + currency + "") @@ -384,7 +384,7 @@ func FormatFloatWithDigitsString(num float64, min, max int) string { return b[0] + "." + b[1][:idx+min] } -func FormatAddCommasFormated(num float64, precision uint) template.HTML { +func FormatAddCommasFormatted(num float64, precision uint) template.HTML { p := message.NewPrinter(language.English) s := p.Sprintf(fmt.Sprintf("%%.%vf", precision), num) if precision > 0 { @@ -394,7 +394,7 @@ func FormatAddCommasFormated(num float64, precision uint) template.HTML { } func FormatBigNumberAddCommasFormated(val hexutil.Big, precision uint) template.HTML { - return FormatAddCommasFormated(float64(val.ToInt().Int64()), 0) + return FormatAddCommasFormatted(float64(val.ToInt().Int64()), 0) } func FormatAddCommas(n uint64) template.HTML { @@ -468,15 +468,15 @@ func FormatBlockStatus(status, slot uint64) template.HTML { func FormatBlockStatusShort(status, slot uint64) template.HTML { // genesis Genesis if status == 0 && SlotToTime(slot).Before(time.Now().Add(time.Minute*-1)) { - return `Miss.` + return `Miss.` } else if status == 0 { - return `Sche.` + return `Sche.` } else if status == 1 { - return `Prop.` + return `Prop.` } else if status == 2 { - return `Miss.` + return `Miss.` } else if status == 3 { - return `Orph.` + return `Orph.` } else { return "Unknown" }