From b9290169d36d2e6d64232ed58016441a23b6ea4f Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Tue, 10 Dec 2024 15:55:35 +0100 Subject: [PATCH] v4: take storage cost into account in RenewalCost --- rhp/v4/rhp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rhp/v4/rhp.go b/rhp/v4/rhp.go index 3e454c4..c39e721 100644 --- a/rhp/v4/rhp.go +++ b/rhp/v4/rhp.go @@ -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 }