@@ -121,28 +121,28 @@ func (k Keeper) CalculatePrice(
121
121
lastTime = status .Since .Unix () + transitionTime
122
122
}
123
123
124
- priceVal , err := k .GetValidatorPrice (ctx , feed .SignalID , address )
124
+ valPrice , err := k .GetValidatorPrice (ctx , feed .SignalID , address )
125
125
if err == nil {
126
126
// 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 {
128
128
priceFeedInfos = append (
129
129
priceFeedInfos , types.PriceFeedInfo {
130
- PriceStatus : priceVal .PriceStatus ,
131
- Price : priceVal .Price ,
130
+ PriceStatus : valPrice .PriceStatus ,
131
+ Price : valPrice .Price ,
132
132
Power : power ,
133
133
Deviation : 0 ,
134
- Timestamp : priceVal .Timestamp ,
134
+ Timestamp : valPrice .Timestamp ,
135
135
Index : idx ,
136
136
},
137
137
)
138
138
}
139
139
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
142
142
}
143
143
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
146
146
}
147
147
}
148
148
@@ -206,19 +206,19 @@ func (k Keeper) GetValidatorPricesIterator(ctx sdk.Context, signalID string) sdk
206
206
}
207
207
208
208
// 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 ) {
210
210
iterator := k .GetValidatorPricesIterator (ctx , signalID )
211
211
defer func (iterator sdk.Iterator ) {
212
212
_ = iterator .Close ()
213
213
}(iterator )
214
214
215
215
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 )
219
219
}
220
220
221
- return priceVals
221
+ return valPrices
222
222
}
223
223
224
224
// GetValidatorPrice gets a price-validator by signal id.
@@ -232,31 +232,31 @@ func (k Keeper) GetValidatorPrice(ctx sdk.Context, signalID string, val sdk.ValA
232
232
)
233
233
}
234
234
235
- var priceVal types.ValidatorPrice
236
- k .cdc .MustUnmarshal (bz , & priceVal )
235
+ var valPrice types.ValidatorPrice
236
+ k .cdc .MustUnmarshal (bz , & valPrice )
237
237
238
- return priceVal , nil
238
+ return valPrice , nil
239
239
}
240
240
241
241
// 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 {
245
245
return err
246
246
}
247
247
}
248
248
return nil
249
249
}
250
250
251
251
// 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 )
254
254
if err != nil {
255
255
return err
256
256
}
257
257
258
258
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 ))
260
260
261
261
return nil
262
262
}
0 commit comments