Skip to content

Commit

Permalink
v4: take storage cost into account in RenewalCost
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Dec 10, 2024
1 parent f356bb7 commit b929016
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rhp/v4/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,10 @@ func ContractCost(cs consensus.State, p HostPrices, fc types.V2FileContract, min
}

// RenewalCost calculates the cost to the host and renter for renewing a contract.
func RenewalCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, minerFee types.Currency) (renter, host types.Currency) {
renter = r.NewContract.RenterOutput.Value.Add(p.ContractPrice).Add(minerFee).Add(cs.V2FileContractTax(r.NewContract)).Sub(r.RenterRollover)
host = r.NewContract.TotalCollateral.Sub(r.HostRollover)
func RenewalCost(cs consensus.State, p HostPrices, r types.V2FileContractRenewal, minerFee types.Currency, prevExpirationHeight uint64) (renter, host types.Currency) {
storageCost := p.StoragePrice.Mul64(r.NewContract.Filesize).Mul64(r.NewContract.ExpirationHeight - prevExpirationHeight)
renter = r.NewContract.RenterOutput.Value.Add(storageCost).Add(p.ContractPrice).Add(minerFee).Add(cs.V2FileContractTax(r.NewContract)).Sub(r.RenterRollover)
host = r.NewContract.HostOutput.Value.Add(r.NewContract.TotalCollateral).Sub(r.HostRollover)
return
}

Expand Down

0 comments on commit b929016

Please sign in to comment.