Skip to content

Commit

Permalink
update lease settlements to 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Feb 13, 2025
1 parent 430c8a1 commit 2c94c7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
v4 "github.com/OmniFlix/omniflixhub/v6/app/upgrades/v4"
v5 "github.com/OmniFlix/omniflixhub/v6/app/upgrades/v5"
v510 "github.com/OmniFlix/omniflixhub/v6/app/upgrades/v510"
v6 "github.com/OmniFlix/omniflixhub/v6/app/upgrades/v6"
)

const Name = "omniflixhub"
Expand All @@ -86,8 +87,17 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
var (
// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string
Upgrades = []upgrades.Upgrade{v012.Upgrade, v2.Upgrade, v2_1.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v510.Upgrade}
Forks []upgrades.Fork
Upgrades = []upgrades.Upgrade{
v012.Upgrade,
v2.Upgrade,
v2_1.Upgrade,
v3.Upgrade,
v4.Upgrade,
v5.Upgrade,
v510.Upgrade,
v6.Upgrade,
}
Forks []upgrades.Fork
)

var _ runtime.AppI = (*OmniFlixApp)(nil)
Expand Down
6 changes: 3 additions & 3 deletions x/medianode/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (k Keeper) CancelLease(ctx sdk.Context, mediaNodeId uint64, sender sdk.AccA
}

// Calculate remaining lease days and refund amount //TODO: change to 24
remainingDays := uint64(lease.LeasedDays) - uint64(ctx.BlockTime().Sub(lease.StartTime).Minutes())
remainingDays := uint64(lease.LeasedDays) - uint64(ctx.BlockTime().Sub(lease.StartTime).Hours()/24)
if remainingDays > 0 {
refundAmount := sdk.NewCoin(
mediaNode.PricePerDay.Denom,
Expand Down Expand Up @@ -260,8 +260,8 @@ func (k Keeper) SettleActiveLeases(ctx sdk.Context) error {
var lease types.Lease
k.cdc.MustUnmarshal(iterator.Value(), &lease)
if lease.Status == types.LEASE_STATUS_ACTIVE &&
ctx.BlockTime().Sub(lease.StartTime).Minutes() >= 5 &&
ctx.BlockTime().Sub(lease.LastSettledAt).Minutes() >= 5 {
ctx.BlockTime().Sub(lease.StartTime).Hours() >= 24 &&
ctx.BlockTime().Sub(lease.LastSettledAt).Hours() >= 24 {

// Calculate payment amount
paymentAmount := sdk.NewCoin(
Expand Down

0 comments on commit 2c94c7f

Please sign in to comment.