@@ -265,15 +265,9 @@ func (pm *pinManager) updateGougingSettings(ctx context.Context, pins api.Gougin
265
265
if err != nil {
266
266
pm .logger .Warn ("failed to convert max download price to currency" )
267
267
} else if ! gs .MaxDownloadPrice .Equals (update ) {
268
- bkp := gs .MaxDownloadPrice
269
268
gs .MaxDownloadPrice = update
270
- if err := gs .Validate (); err != nil {
271
- pm .logger .Warn ("failed to update gouging setting, new download price makes the setting invalid" , zap .Error (err ))
272
- gs .MaxDownloadPrice = bkp
273
- } else {
274
- pm .logger .Infow ("updating max download price" , "old" , bkp , "new" , gs .MaxDownloadPrice , "rate" , rate )
275
- updated = true
276
- }
269
+ pm .logger .Infow ("updating max download price" , "old" , gs .MaxDownloadPrice , "new" , update , "rate" , rate )
270
+ updated = true
277
271
}
278
272
}
279
273
@@ -283,15 +277,9 @@ func (pm *pinManager) updateGougingSettings(ctx context.Context, pins api.Gougin
283
277
if err != nil {
284
278
pm .logger .Warnw ("failed to convert max RPC price to currency" , zap .Error (err ))
285
279
} else if ! gs .MaxRPCPrice .Equals (update ) {
286
- bkp := gs .MaxRPCPrice
280
+ pm . logger . Infow ( "updating max RPC price" , "old" , gs .MaxRPCPrice , "new" , update , "rate" , rate )
287
281
gs .MaxRPCPrice = update
288
- if err := gs .Validate (); err != nil {
289
- pm .logger .Warnw ("failed to update gouging setting, new RPC price makes the setting invalid" , zap .Error (err ))
290
- gs .MaxRPCPrice = bkp
291
- } else {
292
- pm .logger .Infow ("updating max RPC price" , "old" , bkp , "new" , gs .MaxRPCPrice , "rate" , rate )
293
- updated = true
294
- }
282
+ updated = true
295
283
}
296
284
}
297
285
@@ -300,18 +288,10 @@ func (pm *pinManager) updateGougingSettings(ctx context.Context, pins api.Gougin
300
288
maxStorageCurr , err := convertCurrencyToSC (decimal .NewFromFloat (pins .MaxStorage .Value ), rate )
301
289
if err != nil {
302
290
pm .logger .Warnw ("failed to convert max storage price to currency" , zap .Error (err ))
303
- }
304
- update := maxStorageCurr .Div64 (1e12 ).Div64 (144 * 30 ) // convert from SC/TB/month to SC/byte/block
305
- if ! gs .MaxStoragePrice .Equals (update ) {
306
- bkp := gs .MaxStoragePrice
291
+ } else if update := maxStorageCurr .Div64 (1e12 ).Div64 (144 * 30 ); ! gs .MaxStoragePrice .Equals (update ) { // convert from SC/TB/month to SC/byte/block
292
+ pm .logger .Infow ("updating max storage price" , "old" , gs .MaxStoragePrice , "new" , update , "rate" , rate )
307
293
gs .MaxStoragePrice = update
308
- if err := gs .Validate (); err != nil {
309
- pm .logger .Warnw ("failed to update gouging setting, new storage price makes the setting invalid" , zap .Error (err ))
310
- gs .MaxStoragePrice = bkp
311
- } else {
312
- pm .logger .Infow ("updating max storage price" , "old" , bkp , "new" , gs .MaxStoragePrice , "rate" , rate )
313
- updated = true
314
- }
294
+ updated = true
315
295
}
316
296
}
317
297
@@ -321,15 +301,9 @@ func (pm *pinManager) updateGougingSettings(ctx context.Context, pins api.Gougin
321
301
if err != nil {
322
302
pm .logger .Warnw ("failed to convert max upload price to currency" , zap .Error (err ))
323
303
} else if ! gs .MaxUploadPrice .Equals (update ) {
324
- bkp := gs .MaxUploadPrice
304
+ pm . logger . Infow ( "updating max upload price" , "old" , gs .MaxUploadPrice , "new" , update , "rate" , rate )
325
305
gs .MaxUploadPrice = update
326
- if err := gs .Validate (); err != nil {
327
- pm .logger .Warnw ("failed to update gouging setting, new upload price makes the setting invalid" , zap .Error (err ))
328
- gs .MaxUploadPrice = bkp
329
- } else {
330
- pm .logger .Infow ("updating max upload price" , "old" , bkp , "new" , gs .MaxUploadPrice , "rate" , rate )
331
- updated = true
332
- }
306
+ updated = true
333
307
}
334
308
}
335
309
0 commit comments