2019-10-23 13:04:54 +01:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package paymentsconfig
2019-11-15 14:27:44 +00:00
import (
2021-03-30 00:37:46 +01:00
"strconv"
2020-03-16 19:34:15 +00:00
"storj.io/common/memory"
2019-11-15 14:27:44 +00:00
"storj.io/storj/satellite/payments/stripecoinpayments"
)
2019-10-23 13:04:54 +01:00
// Config defines global payments config.
type Config struct {
2020-04-08 11:19:06 +01:00
Provider string ` help:"payments provider to use" default:"" `
StripeCoinPayments stripecoinpayments . Config
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
StorageTBPrice string ` help:"price user should pay for storing TB per month" default:"4" testDefault:"10" `
EgressTBPrice string ` help:"price user should pay for each TB of egress" default:"7" testDefault:"45" `
ObjectPrice string ` help:"price user should pay for each object stored in network per month" default:"0" testDefault:"0.0000022" `
2021-03-30 00:37:46 +01:00
BonusRate int64 ` help:"amount of percents that user will earn as bonus credits by depositing in STORJ tokens" default:"10" `
testplanet/satellite: reduce the number of places default values need to be configured
Satellites set their configuration values to default values using
cfgstruct, however, it turns out our tests don't test these values
at all! Instead, they have a completely separate definition system
that is easy to forget about.
As is to be expected, these values have drifted, and it appears
in a few cases test planet is testing unreasonable values that we
won't see in production, or perhaps worse, features enabled in
production were missed and weren't enabled in testplanet.
This change makes it so all values are configured the same,
systematic way, so it's easy to see when test values are different
than dev values or release values, and it's less hard to forget
to enable features in testplanet.
In terms of reviewing, this change should be actually fairly
easy to review, considering private/testplanet/satellite.go keeps
the current config system and the new one and confirms that they
result in identical configurations, so you can be certain that
nothing was missed and the config is all correct.
You can also check the config lock to see what actual config
values changed.
Change-Id: I6715d0794887f577e21742afcf56fd2b9d12170e
2021-05-31 22:15:00 +01:00
CouponValue int64 ` help:"coupon value in cents" default:"165" testDefault:"275" `
CouponDuration CouponDuration ` help:"duration a new coupon is valid in months/billing cycles. An empty string means the coupon never expires" default:"1" testDefault:"2" `
2021-03-30 00:37:46 +01:00
CouponProjectLimit memory . Size ` help:"project limit to which increase to after applying the coupon, 0 B means not changing it from the default" default:"0 B" `
MinCoinPayment int64 ` help:"minimum value of coin payments in cents before coupon is applied" default:"1000" `
NodeEgressBandwidthPrice int64 ` help:"price node receive for storing TB of egress in cents" default:"2000" `
NodeRepairBandwidthPrice int64 ` help:"price node receive for storing TB of repair in cents" default:"1000" `
NodeAuditBandwidthPrice int64 ` help:"price node receive for storing TB of audit in cents" default:"1000" `
NodeDiskSpacePrice int64 ` help:"price node receive for storing disk space in cents/TB" default:"150" `
}
// CouponDuration is a configuration struct that keeps details about default
// promotional coupon duration.
//
// Can be used as a flag.
type CouponDuration struct {
Enabled bool
BillingPeriods int64
}
2021-04-15 18:53:09 +01:00
// PricingValues holds pricing model for satellite.
type PricingValues struct {
StorageTBPrice string
EgressTBPrice string
ObjectPrice string
}
2021-03-30 00:37:46 +01:00
// Type implements pflag.Value.
func ( CouponDuration ) Type ( ) string { return "paymentsconfig.CouponDuration" }
// String is required for pflag.Value.
func ( cd * CouponDuration ) String ( ) string {
if ! cd . Enabled {
return ""
}
return strconv . FormatInt ( cd . BillingPeriods , 10 )
}
// Set sets the value from a string.
func ( cd * CouponDuration ) Set ( s string ) error {
if s == "" {
cd . Enabled = false
return nil
}
cd . Enabled = true
billingPeriods , err := strconv . ParseInt ( s , 10 , 64 )
if err != nil {
return err
}
cd . BillingPeriods = billingPeriods
return nil
}
// IntPointer returns an int64 pointer representation of the config value.
func ( cd * CouponDuration ) IntPointer ( ) * int64 {
if ! cd . Enabled {
return nil
}
return & cd . BillingPeriods
2019-10-23 13:04:54 +01:00
}