@@ -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,33 +277,21 @@ 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
298
286
// update max storage price
299
287
if pins .MaxStorage .IsPinned () {
300
- update , err := convertCurrencyToSC (decimal .NewFromFloat (pins .MaxStorage .Value ), rate )
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
- } else if ! gs .MaxStoragePrice .Equals (update ) {
304
- 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 )
305
293
gs .MaxStoragePrice = update
306
- if err := gs .Validate (); err != nil {
307
- pm .logger .Warnw ("failed to update gouging setting, new storage price makes the setting invalid" , zap .Error (err ))
308
- gs .MaxStoragePrice = bkp
309
- } else {
310
- pm .logger .Infow ("updating max storage price" , "old" , bkp , "new" , gs .MaxStoragePrice , "rate" , rate )
311
- updated = true
312
- }
294
+ updated = true
313
295
}
314
296
}
315
297
@@ -319,15 +301,9 @@ func (pm *pinManager) updateGougingSettings(ctx context.Context, pins api.Gougin
319
301
if err != nil {
320
302
pm .logger .Warnw ("failed to convert max upload price to currency" , zap .Error (err ))
321
303
} else if ! gs .MaxUploadPrice .Equals (update ) {
322
- bkp := gs .MaxUploadPrice
304
+ pm . logger . Infow ( "updating max upload price" , "old" , gs .MaxUploadPrice , "new" , update , "rate" , rate )
323
305
gs .MaxUploadPrice = update
324
- if err := gs .Validate (); err != nil {
325
- pm .logger .Warnw ("failed to update gouging setting, new upload price makes the setting invalid" , zap .Error (err ))
326
- gs .MaxUploadPrice = bkp
327
- } else {
328
- pm .logger .Infow ("updating max upload price" , "old" , bkp , "new" , gs .MaxUploadPrice , "rate" , rate )
329
- updated = true
330
- }
306
+ updated = true
331
307
}
332
308
}
333
309
0 commit comments