Skip to content

Commit 57efa98

Browse files
committed
fix variable name
1 parent df35f5f commit 57efa98

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

x/feeds/keeper/grpc_query.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ func (q queryServer) ValidatorPrices(
113113
return nil, err
114114
}
115115

116-
var priceVals []types.ValidatorPrice
116+
var valPrices []types.ValidatorPrice
117117

118118
feeds := q.keeper.GetSupportedFeeds(ctx).Feeds
119119
for _, feed := range feeds {
120-
priceVal, err := q.keeper.GetValidatorPrice(ctx, feed.SignalID, val)
120+
valPrice, err := q.keeper.GetValidatorPrice(ctx, feed.SignalID, val)
121121
if err == nil {
122-
priceVals = append(priceVals, priceVal)
122+
valPrices = append(valPrices, valPrice)
123123
}
124124
}
125125

126126
return &types.QueryValidatorPricesResponse{
127-
ValidatorPrices: priceVals,
127+
ValidatorPrices: valPrices,
128128
}, nil
129129
}
130130

@@ -139,13 +139,13 @@ func (q queryServer) ValidatorPrice(
139139
return nil, err
140140
}
141141

142-
priceVal, err := q.keeper.GetValidatorPrice(ctx, req.SignalId, val)
142+
valPrice, err := q.keeper.GetValidatorPrice(ctx, req.SignalId, val)
143143
if err != nil {
144144
return nil, err
145145
}
146146

147147
return &types.QueryValidatorPriceResponse{
148-
ValidatorPrice: priceVal,
148+
ValidatorPrice: valPrice,
149149
}, nil
150150
}
151151

x/feeds/keeper/grpc_query_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ func (suite *KeeperTestSuite) TestQueryPrice() {
136136
}
137137
suite.feedsKeeper.SetPrice(ctx, price)
138138

139-
priceVal := types.ValidatorPrice{
139+
valPrice := types.ValidatorPrice{
140140
PriceStatus: types.PriceStatusAvailable,
141141
Validator: ValidValidator.String(),
142142
SignalID: "crypto_price.bandusd",
143143
Price: 1e9,
144144
Timestamp: ctx.BlockTime().Unix(),
145145
}
146-
err := suite.feedsKeeper.SetValidatorPrice(ctx, priceVal)
146+
err := suite.feedsKeeper.SetValidatorPrice(ctx, valPrice)
147147
suite.Require().NoError(err)
148148

149149
// query and check
@@ -181,7 +181,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorPrices() {
181181

182182
suite.feedsKeeper.SetSupportedFeeds(ctx, feeds)
183183

184-
priceVals := []types.ValidatorPrice{
184+
valPrices := []types.ValidatorPrice{
185185
{
186186
Validator: ValidValidator.String(),
187187
SignalID: "crypto_price.atomusd",
@@ -195,8 +195,8 @@ func (suite *KeeperTestSuite) TestQueryValidatorPrices() {
195195
Timestamp: ctx.BlockTime().Unix(),
196196
},
197197
}
198-
for _, priceVal := range priceVals {
199-
err := suite.feedsKeeper.SetValidatorPrice(ctx, priceVal)
198+
for _, valPrice := range valPrices {
199+
err := suite.feedsKeeper.SetValidatorPrice(ctx, valPrice)
200200
suite.Require().NoError(err)
201201
}
202202

@@ -206,7 +206,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorPrices() {
206206
})
207207
suite.Require().NoError(err)
208208
suite.Require().Equal(&types.QueryValidatorPricesResponse{
209-
ValidatorPrices: priceVals,
209+
ValidatorPrices: valPrices,
210210
}, res)
211211

212212
res, err = queryClient.ValidatorPrices(gocontext.Background(), &types.QueryValidatorPricesRequest{
@@ -222,13 +222,13 @@ func (suite *KeeperTestSuite) TestQueryValidatorPrice() {
222222
ctx, queryClient := suite.ctx, suite.queryClient
223223

224224
// setup
225-
priceVal := types.ValidatorPrice{
225+
valPrice := types.ValidatorPrice{
226226
Validator: ValidValidator.String(),
227227
SignalID: "crypto_price.bandusd",
228228
Price: 1e9,
229229
Timestamp: ctx.BlockTime().Unix(),
230230
}
231-
err := suite.feedsKeeper.SetValidatorPrice(ctx, priceVal)
231+
err := suite.feedsKeeper.SetValidatorPrice(ctx, valPrice)
232232
suite.Require().NoError(err)
233233

234234
// query and check
@@ -238,7 +238,7 @@ func (suite *KeeperTestSuite) TestQueryValidatorPrice() {
238238
})
239239
suite.Require().NoError(err)
240240
suite.Require().Equal(&types.QueryValidatorPriceResponse{
241-
ValidatorPrice: priceVal,
241+
ValidatorPrice: valPrice,
242242
}, res)
243243

244244
res, err = queryClient.ValidatorPrice(gocontext.Background(), &types.QueryValidatorPriceRequest{

x/feeds/keeper/keeper_price.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ func (k Keeper) CalculatePrice(
121121
lastTime = status.Since.Unix() + transitionTime
122122
}
123123

124-
priceVal, err := k.GetValidatorPrice(ctx, feed.SignalID, address)
124+
valPrice, err := k.GetValidatorPrice(ctx, feed.SignalID, address)
125125
if err == nil {
126126
// if timestamp of price is in acception period, append it
127-
if priceVal.Timestamp >= blockTime.Unix()-feed.Interval {
127+
if valPrice.Timestamp >= blockTime.Unix()-feed.Interval {
128128
priceFeedInfos = append(
129129
priceFeedInfos, types.PriceFeedInfo{
130-
PriceStatus: priceVal.PriceStatus,
131-
Price: priceVal.Price,
130+
PriceStatus: valPrice.PriceStatus,
131+
Price: valPrice.Price,
132132
Power: power,
133133
Deviation: 0,
134-
Timestamp: priceVal.Timestamp,
134+
Timestamp: valPrice.Timestamp,
135135
Index: idx,
136136
},
137137
)
138138
}
139139

140-
if priceVal.Timestamp+feed.Interval > lastTime {
141-
lastTime = priceVal.Timestamp + feed.Interval
140+
if valPrice.Timestamp+feed.Interval > lastTime {
141+
lastTime = valPrice.Timestamp + feed.Interval
142142
}
143143

144-
if priceVal.BlockHeight+feed.Interval/timePerBlock > lastBlock {
145-
lastBlock = priceVal.BlockHeight + feed.Interval/timePerBlock
144+
if valPrice.BlockHeight+feed.Interval/timePerBlock > lastBlock {
145+
lastBlock = valPrice.BlockHeight + feed.Interval/timePerBlock
146146
}
147147
}
148148

@@ -206,19 +206,19 @@ func (k Keeper) GetValidatorPricesIterator(ctx sdk.Context, signalID string) sdk
206206
}
207207

208208
// GetValidatorPrices gets a list of all price-validators.
209-
func (k Keeper) GetValidatorPrices(ctx sdk.Context, signalID string) (priceVals []types.ValidatorPrice) {
209+
func (k Keeper) GetValidatorPrices(ctx sdk.Context, signalID string) (valPrices []types.ValidatorPrice) {
210210
iterator := k.GetValidatorPricesIterator(ctx, signalID)
211211
defer func(iterator sdk.Iterator) {
212212
_ = iterator.Close()
213213
}(iterator)
214214

215215
for ; iterator.Valid(); iterator.Next() {
216-
var priceVal types.ValidatorPrice
217-
k.cdc.MustUnmarshal(iterator.Value(), &priceVal)
218-
priceVals = append(priceVals, priceVal)
216+
var valPrice types.ValidatorPrice
217+
k.cdc.MustUnmarshal(iterator.Value(), &valPrice)
218+
valPrices = append(valPrices, valPrice)
219219
}
220220

221-
return priceVals
221+
return valPrices
222222
}
223223

224224
// GetValidatorPrice gets a price-validator by signal id.
@@ -232,31 +232,31 @@ func (k Keeper) GetValidatorPrice(ctx sdk.Context, signalID string, val sdk.ValA
232232
)
233233
}
234234

235-
var priceVal types.ValidatorPrice
236-
k.cdc.MustUnmarshal(bz, &priceVal)
235+
var valPrice types.ValidatorPrice
236+
k.cdc.MustUnmarshal(bz, &valPrice)
237237

238-
return priceVal, nil
238+
return valPrice, nil
239239
}
240240

241241
// SetValidatorPrices sets multiple price-validator.
242-
func (k Keeper) SetValidatorPrices(ctx sdk.Context, priceVals []types.ValidatorPrice) error {
243-
for _, priceVal := range priceVals {
244-
if err := k.SetValidatorPrice(ctx, priceVal); err != nil {
242+
func (k Keeper) SetValidatorPrices(ctx sdk.Context, valPrices []types.ValidatorPrice) error {
243+
for _, valPrice := range valPrices {
244+
if err := k.SetValidatorPrice(ctx, valPrice); err != nil {
245245
return err
246246
}
247247
}
248248
return nil
249249
}
250250

251251
// SetValidatorPrice sets a new price-validator or replace if price-validator with the same signal id and validator address existed.
252-
func (k Keeper) SetValidatorPrice(ctx sdk.Context, priceVal types.ValidatorPrice) error {
253-
valAddress, err := sdk.ValAddressFromBech32(priceVal.Validator)
252+
func (k Keeper) SetValidatorPrice(ctx sdk.Context, valPrice types.ValidatorPrice) error {
253+
valAddress, err := sdk.ValAddressFromBech32(valPrice.Validator)
254254
if err != nil {
255255
return err
256256
}
257257

258258
ctx.KVStore(k.storeKey).
259-
Set(types.ValidatorPriceStoreKey(priceVal.SignalID, valAddress), k.cdc.MustMarshal(&priceVal))
259+
Set(types.ValidatorPriceStoreKey(valPrice.SignalID, valAddress), k.cdc.MustMarshal(&valPrice))
260260

261261
return nil
262262
}

x/feeds/keeper/keeper_price_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ func (suite *KeeperTestSuite) TestGetSetDeleteValidatorPrice() {
5555
ctx := suite.ctx
5656

5757
// set
58-
expPriceVal := types.ValidatorPrice{
58+
expValPrice := types.ValidatorPrice{
5959
Validator: ValidValidator.String(),
6060
SignalID: "crypto_price.bandusd",
6161
Price: 1e10,
6262
Timestamp: ctx.BlockTime().Unix(),
6363
}
64-
err := suite.feedsKeeper.SetValidatorPrice(ctx, expPriceVal)
64+
err := suite.feedsKeeper.SetValidatorPrice(ctx, expValPrice)
6565
suite.Require().NoError(err)
6666

6767
// get
68-
priceVal, err := suite.feedsKeeper.GetValidatorPrice(ctx, "crypto_price.bandusd", ValidValidator)
68+
valPrice, err := suite.feedsKeeper.GetValidatorPrice(ctx, "crypto_price.bandusd", ValidValidator)
6969
suite.Require().NoError(err)
70-
suite.Require().Equal(expPriceVal, priceVal)
70+
suite.Require().Equal(expValPrice, valPrice)
7171

7272
// delete
7373
suite.feedsKeeper.DeleteValidatorPrice(ctx, "crypto_price.bandusd", ValidValidator)
@@ -81,7 +81,7 @@ func (suite *KeeperTestSuite) TestGetSetValidatorPrices() {
8181
ctx := suite.ctx
8282

8383
// set
84-
expPriceVals := []types.ValidatorPrice{
84+
expValPrices := []types.ValidatorPrice{
8585
{
8686
Validator: ValidValidator.String(),
8787
SignalID: "crypto_price.bandusd",
@@ -95,12 +95,12 @@ func (suite *KeeperTestSuite) TestGetSetValidatorPrices() {
9595
Timestamp: ctx.BlockTime().Unix(),
9696
},
9797
}
98-
err := suite.feedsKeeper.SetValidatorPrices(ctx, expPriceVals)
98+
err := suite.feedsKeeper.SetValidatorPrices(ctx, expValPrices)
9999
suite.Require().NoError(err)
100100

101101
// get
102-
priceVals := suite.feedsKeeper.GetValidatorPrices(ctx, "crypto_price.bandusd")
103-
suite.Require().Equal(expPriceVals, priceVals)
102+
valPrices := suite.feedsKeeper.GetValidatorPrices(ctx, "crypto_price.bandusd")
103+
suite.Require().Equal(expValPrices, valPrices)
104104
}
105105

106106
func (suite *KeeperTestSuite) TestCalculatePrice() {

x/feeds/keeper/msg_server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ func (ms msgServer) SubmitPrices(
126126
}
127127

128128
// check if price is not too fast
129-
priceVal, err := ms.GetValidatorPrice(ctx, price.SignalID, val)
130-
if err == nil && blockTime < priceVal.Timestamp+cooldownTime {
129+
valPrice, err := ms.GetValidatorPrice(ctx, price.SignalID, val)
130+
if err == nil && blockTime < valPrice.Timestamp+cooldownTime {
131131
tooEarlyPriceSubmission++
132132
}
133133

134-
valPrice := ms.NewValidatorPrice(val, price, blockTime, blockHeight)
134+
valPrice = ms.NewValidatorPrice(val, price, blockTime, blockHeight)
135135

136136
if err = ms.SetValidatorPrice(ctx, valPrice); err != nil {
137137
return nil, err

0 commit comments

Comments
 (0)