@@ -14,7 +14,6 @@ import (
1414 "github.com/prometheus/client_golang/prometheus"
1515
1616 berrors "github.com/letsencrypt/boulder/errors"
17- "github.com/letsencrypt/boulder/features"
1817)
1918
2019const (
@@ -276,7 +275,6 @@ func (l *Limiter) BatchSpend(ctx context.Context, txns []Transaction) (*Decision
276275 return nil , err
277276 }
278277 batchDecision := allowedDecision
279- newTATs := make (map [string ]time.Time )
280278 newBuckets := make (map [string ]time.Time )
281279 incrBuckets := make (map [string ]increment )
282280 txnOutcomes := make (map [Transaction ]string )
@@ -297,8 +295,6 @@ func (l *Limiter) BatchSpend(ctx context.Context, txns []Transaction) (*Decision
297295
298296 if d .allowed && (tat != d .newTAT ) && txn .spend {
299297 // New bucket state should be persisted.
300- newTATs [txn .bucketKey ] = d .newTAT
301-
302298 if bucketExists {
303299 incrBuckets [txn .bucketKey ] = increment {
304300 cost : time .Duration (txn .cost * txn .limit .emissionInterval ),
@@ -321,25 +317,16 @@ func (l *Limiter) BatchSpend(ctx context.Context, txns []Transaction) (*Decision
321317 }
322318 }
323319
324- if features .Get ().IncrementRateLimits {
325- if batchDecision .allowed {
326- if len (newBuckets ) > 0 {
327- err = l .source .BatchSet (ctx , newBuckets )
328- if err != nil {
329- return nil , err
330- }
331- }
332-
333- if len (incrBuckets ) > 0 {
334- err = l .source .BatchIncrement (ctx , incrBuckets )
335- if err != nil {
336- return nil , err
337- }
320+ if batchDecision .allowed {
321+ if len (newBuckets ) > 0 {
322+ err = l .source .BatchSet (ctx , newBuckets )
323+ if err != nil {
324+ return nil , err
338325 }
339326 }
340- } else {
341- if batchDecision . allowed && len (newTATs ) > 0 {
342- err = l .source .BatchSet (ctx , newTATs )
327+
328+ if len (incrBuckets ) > 0 {
329+ err = l .source .BatchIncrement (ctx , incrBuckets )
343330 if err != nil {
344331 return nil , err
345332 }
@@ -396,7 +383,6 @@ func (l *Limiter) BatchRefund(ctx context.Context, txns []Transaction) (*Decisio
396383 }
397384
398385 batchDecision := allowedDecision
399- newTATs := make (map [string ]time.Time )
400386 incrBuckets := make (map [string ]increment )
401387
402388 for _ , txn := range batch {
@@ -414,27 +400,17 @@ func (l *Limiter) BatchRefund(ctx context.Context, txns []Transaction) (*Decisio
414400 batchDecision = stricter (batchDecision , d )
415401 if d .allowed && tat != d .newTAT {
416402 // New bucket state should be persisted.
417- newTATs [txn .bucketKey ] = d .newTAT
418403 incrBuckets [txn .bucketKey ] = increment {
419404 cost : time .Duration (- txn .cost * txn .limit .emissionInterval ),
420405 ttl : time .Duration (txn .limit .burstOffset ),
421406 }
422407 }
423408 }
424409
425- if features .Get ().IncrementRateLimits {
426- if len (incrBuckets ) > 0 {
427- err = l .source .BatchIncrement (ctx , incrBuckets )
428- if err != nil {
429- return nil , err
430- }
431- }
432- } else {
433- if len (newTATs ) > 0 {
434- err = l .source .BatchSet (ctx , newTATs )
435- if err != nil {
436- return nil , err
437- }
410+ if len (incrBuckets ) > 0 {
411+ err = l .source .BatchIncrement (ctx , incrBuckets )
412+ if err != nil {
413+ return nil , err
438414 }
439415 }
440416 return batchDecision , nil
0 commit comments