Skip to content

Commit 7daf98e

Browse files
author
Mak Muftic
committed
Change default reward to -1
1 parent 1923c4b commit 7daf98e

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

cmd/payout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func init() {
4949
payoutCmd.Flags().StringVar(
5050
&totalReward,
5151
"payout-reward",
52-
"",
52+
"-1",
5353
"[REQUIRED] total reward pool in Planck",
5454
)
5555
payoutCmd.Flags().StringVar(

cmd/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func init() {
230230
startCmd.Flags().StringVar(
231231
&payoutTotalReward,
232232
"payout-reward",
233-
"",
233+
"-1",
234234
"[OPTIONAL] Total reward pool in Planck. If omitted, total balance of load balancer wallet will be considered as payout reward",
235235
)
236236

cmd/validation.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ func ValidatePayoutFlags(
1515
var err error
1616
var rewardAsFloat64 float64
1717

18-
if payoutReward == "" {
18+
// if total reward is determined as wallet balance
19+
if payoutReward == "-1" {
1920
if payoutAddress == "" {
2021
return 0, errors.New("Unable to set reward amount to entire wallet balance if fee address not provided")
2122
} else {
@@ -35,7 +36,7 @@ func ValidatePayoutFlags(
3536
}
3637
} else {
3738
rewardAsFloat64, err = strconv.ParseFloat(payoutReward, 64)
38-
if err != nil {
39+
if err != nil || rewardAsFloat64 < -1 {
3940
return 0, errors.New("invalid total reward value")
4041
}
4142
}

internal/script/payout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func ExecutePayout(
3939
return nil, fmt.Errorf("invalid private key, %v", err)
4040
}
4141

42-
if totalReward == 0 {
43-
// distribute entire balance on address if total reward not set
42+
// distribute entire balance on address if total reward not set
43+
if totalReward == -1 {
4444
balance, err := payout.GetBalance(metadataLatest, keyringPair, substrateAPI)
4545
if err != nil {
4646
return nil, err

0 commit comments

Comments
 (0)