Skip to content

Commit 9e6e4f1

Browse files
committed
fix: rename incorrect methods for hours and gigabytes
1 parent d3edbd6 commit 9e6e4f1

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

x/lease/types/v1/lease.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ func (m *Lease) DepositAmount() sdk.Coin {
1818
return sdk.Coin{Denom: m.Price.Denom, Amount: amount}
1919
}
2020

21-
// GetHours returns the duration the lease has been used in time.Duration.
22-
func (m *Lease) GetHours() time.Duration {
21+
// GetDuration returns the duration the lease has been used in time.Duration.
22+
func (m *Lease) GetDuration() time.Duration {
2323
return time.Duration(m.Hours) * time.Hour
2424
}
2525

26-
// GetMaxHours returns the total maximum duration of the lease in time.Duration.
27-
func (m *Lease) GetMaxHours() time.Duration {
26+
// GetMaxDuration returns the total maximum duration of the lease in time.Duration.
27+
func (m *Lease) GetMaxDuration() time.Duration {
2828
return time.Duration(m.MaxHours) * time.Hour
2929
}
3030

3131
// InactiveAt returns the time when the lease becomes inactive,.
3232
func (m *Lease) InactiveAt() time.Time {
33-
return m.StartAt.Add(m.GetMaxHours())
33+
return m.StartAt.Add(m.GetMaxDuration())
3434
}
3535

3636
// PayoutAt returns the time when the lease's payout should occur.
3737
func (m *Lease) PayoutAt() time.Time {
3838
if m.Hours < m.MaxHours {
39-
return m.StartAt.Add(m.GetHours())
39+
return m.StartAt.Add(m.GetDuration())
4040
}
4141

4242
return time.Time{}

x/node/keeper/msg_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ func (k *Keeper) HandleMsgStartSession(ctx sdk.Context, msg *v3.MsgStartSessionR
264264
NodeAddress: nodeAddr.String(),
265265
DownloadBytes: sdkmath.ZeroInt(),
266266
UploadBytes: sdkmath.ZeroInt(),
267-
MaxBytes: msg.GetGigabytes(),
267+
MaxBytes: msg.GetBytes(),
268268
Duration: 0,
269-
MaxDuration: msg.GetHours(),
269+
MaxDuration: msg.GetDuration(),
270270
Status: v1base.StatusActive,
271271
InactiveAt: inactiveAt,
272272
StartAt: ctx.BlockTime(),

x/node/types/v3/msg.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ func NewMsgStartSessionRequest(from sdk.AccAddress, nodeAddr base.NodeAddress, g
179179
}
180180
}
181181

182-
// GetGigabytes returns the total data usage in bytes for MsgStartSessionRequest.
183-
func (m *MsgStartSessionRequest) GetGigabytes() sdkmath.Int {
182+
// GetBytes returns the total data usage in bytes for MsgStartSessionRequest.
183+
func (m *MsgStartSessionRequest) GetBytes() sdkmath.Int {
184184
return base.Gigabyte.MulRaw(m.Gigabytes)
185185
}
186186

187-
// GetHours returns the session duration in time.Duration from MsgStartSessionRequest.
188-
func (m *MsgStartSessionRequest) GetHours() time.Duration {
187+
// GetDuration returns the session duration in time.Duration from MsgStartSessionRequest.
188+
func (m *MsgStartSessionRequest) GetDuration() time.Duration {
189189
return time.Duration(m.Hours) * time.Hour
190190
}
191191

x/plan/types/v3/plan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
v1base "github.com/sentinel-official/sentinelhub/v12/types/v1"
1212
)
1313

14-
// GetGigabytes returns the plan's bandwidth as sdkmath.Int in bytes.
15-
func (m *Plan) GetGigabytes() sdkmath.Int {
14+
// GetBytes returns the plan's bandwidth as sdkmath.Int in bytes.
15+
func (m *Plan) GetBytes() sdkmath.Int {
1616
return base.Gigabyte.MulRaw(m.Gigabytes)
1717
}
1818

19-
// GetHours returns the plan's duration as a time.Duration value.
20-
func (m *Plan) GetHours() time.Duration {
19+
// GetDuration returns the plan's duration as a time.Duration value.
20+
func (m *Plan) GetDuration() time.Duration {
2121
return time.Duration(m.Hours) * time.Hour
2222
}
2323

x/subscription/keeper/msg_handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (k *Keeper) HandleMsgRenewSubscription(ctx sdk.Context, msg *v3.MsgRenewSub
139139
}
140140

141141
// Construct the renewed subscription with updated times and pricing
142-
inactiveAt := ctx.BlockTime().Add(plan.GetHours())
142+
inactiveAt := ctx.BlockTime().Add(plan.GetDuration())
143143
subscription = v3.Subscription{
144144
ID: subscription.ID,
145145
AccAddress: subscription.AccAddress,
@@ -324,7 +324,7 @@ func (k *Keeper) HandleMsgStartSubscription(ctx sdk.Context, msg *v3.MsgStartSub
324324

325325
// Build the subscription object with a new ID
326326
count := k.GetSubscriptionCount(ctx)
327-
inactiveAt := ctx.BlockTime().Add(plan.GetHours())
327+
inactiveAt := ctx.BlockTime().Add(plan.GetDuration())
328328
subscription := v3.Subscription{
329329
ID: count + 1,
330330
AccAddress: accAddr.String(),
@@ -382,7 +382,7 @@ func (k *Keeper) HandleMsgStartSubscription(ctx sdk.Context, msg *v3.MsgStartSub
382382
alloc := v2.Allocation{
383383
ID: subscription.ID,
384384
Address: subscription.AccAddress,
385-
GrantedBytes: plan.GetGigabytes(),
385+
GrantedBytes: plan.GetBytes(),
386386
UtilisedBytes: sdkmath.ZeroInt(),
387387
}
388388

0 commit comments

Comments
 (0)