Documentation
¶
Index ¶
- Constants
- Variables
- type Calculator
- func (c Calculator) CalculateContractOverdue(id uint64, allowance time.Duration) (int64, error)
- func (c *Calculator) CalculateCost(cru, mru, hru, sru uint64, publicIP, certified bool) (float64, error)
- func (c *Calculator) CalculatePricesAfterDiscount(cost float64) (dedicatedPrice, sharedPrice float64, err error)
- func (c *Calculator) TFTtoUSD(tft float64) (float64, error)
- func (c *Calculator) USDtoTFT(usd float64) (float64, error)
Constants ¶
const UnitFactor = 1e7
UnitFactor represents the smallest unit conversion factor for both USD and TFT 1 USD = 10,000,000 unit-USD 1 TFT = 10,000,000 unit-TFT (TFT's Planck)
Variables ¶
var ErrContractDeleted = errors.New("contract is deleted")
Functions ¶
This section is empty.
Types ¶
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator struct for calculating the cost of resources
func NewCalculator ¶
func NewCalculator(substrateConn subi.SubstrateExt, identity substrate.Identity) Calculator
NewCalculator creates a new Calculator
func (Calculator) CalculateContractOverdue ¶ added in v0.16.10
Calculates the overdue amount in TFT.
The overdue amount basically is the sum of three parts:
1- Total over draft: is the sum of additional overdraft and standard overdraft. 2- Unbilled NU: is the unbilled amount of network usage. 3- The estimated cost of the contract for the total period: this part is dependant on the contract type and if the contract is on rented node or not.
If the contract is rent contract, will add both of ipv4 cost and the total overdue of all associated contracts. The total period is the time since the last billing added to Allowance period. The resulting overdue amount represents the amount that needs to be addressed.
func (*Calculator) CalculateCost ¶
func (c *Calculator) CalculateCost(cru, mru, hru, sru uint64, publicIP, certified bool) (float64, error)
CalculateCost calculates the cost in $ per month of the given resources without a discount
func (*Calculator) CalculatePricesAfterDiscount ¶ added in v0.16.10
func (c *Calculator) CalculatePricesAfterDiscount(cost float64) (dedicatedPrice, sharedPrice float64, err error)
CalculatePricesAfterDiscount calculates the prices after discount it takes the cost in USD and returns the prices after discount