@@ -222,20 +222,20 @@ func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb
222222 Expires : parsed .NotAfter ,
223223 }
224224
225- _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
225+ _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
226226 // Select to see if precert exists
227227 var row struct {
228228 Count int64
229229 }
230- err := txWithCtx .SelectOne (ctx , & row , "SELECT COUNT(*) as count FROM precertificates WHERE serial=?" , serialHex )
230+ err := tx .SelectOne (ctx , & row , "SELECT COUNT(*) as count FROM precertificates WHERE serial=?" , serialHex )
231231 if err != nil {
232232 return nil , err
233233 }
234234 if row .Count > 0 {
235235 return nil , berrors .DuplicateError ("cannot add a duplicate cert" )
236236 }
237237
238- err = txWithCtx .Insert (ctx , preCertModel )
238+ err = tx .Insert (ctx , preCertModel )
239239 if err != nil {
240240 return nil , err
241241 }
@@ -268,18 +268,18 @@ func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb
268268 // not for the purpose of rate limiting is the least of our troubles.
269269 isRenewal , err := ssa .checkFQDNSetExists (
270270 ctx ,
271- txWithCtx .SelectOne ,
271+ tx .SelectOne ,
272272 parsed .DNSNames )
273273 if err != nil {
274274 return nil , err
275275 }
276276
277- err = addIssuedNames (ctx , txWithCtx , parsed , isRenewal )
277+ err = addIssuedNames (ctx , tx , parsed , isRenewal )
278278 if err != nil {
279279 return nil , err
280280 }
281281
282- err = addKeyHash (ctx , txWithCtx , parsed )
282+ err = addKeyHash (ctx , tx , parsed )
283283 if err != nil {
284284 return nil , err
285285 }
@@ -315,12 +315,12 @@ func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.Ad
315315 Expires : parsedCertificate .NotAfter ,
316316 }
317317
318- isRenewalRaw , overallError := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
318+ isRenewalRaw , overallError := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
319319 // Select to see if cert exists
320320 var row struct {
321321 Count int64
322322 }
323- err := txWithCtx .SelectOne (ctx , & row , "SELECT COUNT(*) as count FROM certificates WHERE serial=?" , serial )
323+ err := tx .SelectOne (ctx , & row , "SELECT COUNT(*) as count FROM certificates WHERE serial=?" , serial )
324324 if err != nil {
325325 return nil , err
326326 }
@@ -329,7 +329,7 @@ func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.Ad
329329 }
330330
331331 // Save the final certificate
332- err = txWithCtx .Insert (ctx , cert )
332+ err = tx .Insert (ctx , cert )
333333 if err != nil {
334334 return nil , err
335335 }
@@ -342,7 +342,7 @@ func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.Ad
342342 // not for the purpose of rate limiting is the least of our troubles.
343343 isRenewal , err := ssa .checkFQDNSetExists (
344344 ctx ,
345- txWithCtx .SelectOne ,
345+ tx .SelectOne ,
346346 parsedCertificate .DNSNames )
347347 if err != nil {
348348 return nil , err
@@ -369,12 +369,12 @@ func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.Ad
369369 // for rate limits. Since the effects of failing these writes is slight
370370 // miscalculation of rate limits we choose to not fail the AddCertificate
371371 // operation if the rate limit update transaction fails.
372- _ , rlTransactionErr := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
372+ _ , rlTransactionErr := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
373373 // Add to the rate limit table, but only for new certificates. Renewals
374374 // don't count against the certificatesPerName limit.
375375 if ! isRenewal {
376376 timeToTheHour := parsedCertificate .NotBefore .Round (time .Hour )
377- err := ssa .addCertificatesPerName (ctx , txWithCtx , parsedCertificate .DNSNames , timeToTheHour )
377+ err := ssa .addCertificatesPerName (ctx , tx , parsedCertificate .DNSNames , timeToTheHour )
378378 if err != nil {
379379 return nil , err
380380 }
@@ -384,7 +384,7 @@ func (ssa *SQLStorageAuthority) AddCertificate(ctx context.Context, req *sapb.Ad
384384 // limits are calculated correctly.
385385 err = addFQDNSet (
386386 ctx ,
387- txWithCtx ,
387+ tx ,
388388 parsedCertificate .DNSNames ,
389389 core .SerialToString (parsedCertificate .SerialNumber ),
390390 parsedCertificate .NotBefore ,
@@ -454,7 +454,7 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
454454 return nil , errIncompleteRequest
455455 }
456456
457- output , err := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
457+ output , err := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
458458 // First, insert all of the new authorizations and record their IDs.
459459 newAuthzIDs := make ([]int64 , 0 )
460460 if len (req .NewAuthzs ) != 0 {
@@ -488,7 +488,7 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
488488 return nil , err
489489 }
490490 }
491- newAuthzIDs , err = inserter .Insert (ctx , txWithCtx )
491+ newAuthzIDs , err = inserter .Insert (ctx , tx )
492492 if err != nil {
493493 return nil , err
494494 }
@@ -500,7 +500,7 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
500500 Expires : time .Unix (0 , req .NewOrder .Expires ),
501501 Created : ssa .clk .Now (),
502502 }
503- err := txWithCtx .Insert (ctx , order )
503+ err := tx .Insert (ctx , order )
504504 if err != nil {
505505 return nil , err
506506 }
@@ -522,7 +522,7 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
522522 return nil , err
523523 }
524524 }
525- _ , err = inserter .Insert (ctx , txWithCtx )
525+ _ , err = inserter .Insert (ctx , tx )
526526 if err != nil {
527527 return nil , err
528528 }
@@ -538,13 +538,13 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
538538 return nil , err
539539 }
540540 }
541- _ , err = inserter .Insert (ctx , txWithCtx )
541+ _ , err = inserter .Insert (ctx , tx )
542542 if err != nil {
543543 return nil , err
544544 }
545545
546546 // Fifth, insert the FQDNSet entry for the order.
547- err = addOrderFQDNSet (ctx , txWithCtx , req .NewOrder .Names , order .ID , order .RegistrationID , order .Expires )
547+ err = addOrderFQDNSet (ctx , tx , req .NewOrder .Names , order .ID , order .RegistrationID , order .Expires )
548548 if err != nil {
549549 return nil , err
550550 }
@@ -566,7 +566,7 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb
566566
567567 // Calculate the order status before returning it. Since it may have reused
568568 // all valid authorizations the order may be "born" in a ready status.
569- status , err := statusForOrder (ctx , txWithCtx , res , ssa .clk .Now ())
569+ status , err := statusForOrder (ctx , tx , res , ssa .clk .Now ())
570570 if err != nil {
571571 return nil , err
572572 }
@@ -599,8 +599,8 @@ func (ssa *SQLStorageAuthority) SetOrderProcessing(ctx context.Context, req *sap
599599 if req .Id == 0 {
600600 return nil , errIncompleteRequest
601601 }
602- _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
603- result , err := txWithCtx .ExecContext (ctx , `
602+ _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
603+ result , err := tx .ExecContext (ctx , `
604604 UPDATE orders
605605 SET beganProcessing = ?
606606 WHERE id = ?
@@ -630,7 +630,7 @@ func (ssa *SQLStorageAuthority) SetOrderError(ctx context.Context, req *sapb.Set
630630 if req .Id == 0 || req .Error == nil {
631631 return nil , errIncompleteRequest
632632 }
633- _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
633+ _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
634634 om , err := orderToModel (& corepb.Order {
635635 Id : req .Id ,
636636 Error : req .Error ,
@@ -639,7 +639,7 @@ func (ssa *SQLStorageAuthority) SetOrderError(ctx context.Context, req *sapb.Set
639639 return nil , err
640640 }
641641
642- result , err := txWithCtx .ExecContext (ctx , `
642+ result , err := tx .ExecContext (ctx , `
643643 UPDATE orders
644644 SET error = ?
645645 WHERE id = ?` ,
@@ -670,8 +670,8 @@ func (ssa *SQLStorageAuthority) FinalizeOrder(ctx context.Context, req *sapb.Fin
670670 if req .Id == 0 || req .CertificateSerial == "" {
671671 return nil , errIncompleteRequest
672672 }
673- _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
674- result , err := txWithCtx .ExecContext (ctx , `
673+ _ , overallError := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
674+ result , err := tx .ExecContext (ctx , `
675675 UPDATE orders
676676 SET certificateSerial = ?
677677 WHERE id = ? AND
@@ -689,7 +689,7 @@ func (ssa *SQLStorageAuthority) FinalizeOrder(ctx context.Context, req *sapb.Fin
689689
690690 // Delete the orderFQDNSet row for the order now that it has been finalized.
691691 // We use this table for order reuse and should not reuse a finalized order.
692- err = deleteOrderFQDNSet (ctx , txWithCtx , req .Id )
692+ err = deleteOrderFQDNSet (ctx , tx , req .Id )
693693 if err != nil {
694694 return nil , err
695695 }
@@ -942,9 +942,9 @@ func (ssa *SQLStorageAuthority) LeaseCRLShard(ctx context.Context, req *sapb.Lea
942942// leased or are previously-unknown indices are considered older than any other
943943// shard. It returns an error if all shards for the issuer are already leased.
944944func (ssa * SQLStorageAuthority ) leaseOldestCRLShard (ctx context.Context , req * sapb.LeaseCRLShardRequest ) (* sapb.LeaseCRLShardResponse , error ) {
945- shardIdx , err := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
945+ shardIdx , err := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
946946 var shards []* crlShardModel
947- _ , err := txWithCtx .Select (
947+ _ , err := tx .Select (
948948 ctx ,
949949 & shards ,
950950 `SELECT id, issuerID, idx, thisUpdate, nextUpdate, leasedUntil
@@ -993,15 +993,15 @@ func (ssa *SQLStorageAuthority) leaseOldestCRLShard(ctx context.Context, req *sa
993993 }
994994
995995 if needToInsert {
996- _ , err = txWithCtx .ExecContext (ctx ,
996+ _ , err = tx .ExecContext (ctx ,
997997 `INSERT INTO crlShards (issuerID, idx, leasedUntil)
998998 VALUES (?, ?, ?)` ,
999999 req .IssuerNameID ,
10001000 shardIdx ,
10011001 req .Until .AsTime (),
10021002 )
10031003 } else {
1004- _ , err = txWithCtx .ExecContext (ctx ,
1004+ _ , err = tx .ExecContext (ctx ,
10051005 `UPDATE crlShards
10061006 SET leasedUntil = ?
10071007 WHERE issuerID = ?
@@ -1036,8 +1036,8 @@ func (ssa *SQLStorageAuthority) leaseSpecificCRLShard(ctx context.Context, req *
10361036 return nil , fmt .Errorf ("request must identify a single shard index: %d != %d" , req .MinShardIdx , req .MaxShardIdx )
10371037 }
10381038
1039- _ , err := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
1040- res , err := txWithCtx .ExecContext (ctx ,
1039+ _ , err := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
1040+ res , err := tx .ExecContext (ctx ,
10411041 `UPDATE crlShards
10421042 SET leasedUntil = ?
10431043 WHERE issuerID = ?
@@ -1088,8 +1088,8 @@ func (ssa *SQLStorageAuthority) UpdateCRLShard(ctx context.Context, req *sapb.Up
10881088 return nil , errIncompleteRequest
10891089 }
10901090
1091- _ , err := db .WithTransaction (ctx , ssa .dbMap , func (txWithCtx db.Executor ) (interface {}, error ) {
1092- res , err := txWithCtx .ExecContext (ctx ,
1091+ _ , err := db .WithTransaction (ctx , ssa .dbMap , func (tx db.Executor ) (interface {}, error ) {
1092+ res , err := tx .ExecContext (ctx ,
10931093 `UPDATE crlShards
10941094 SET thisUpdate = ?, nextUpdate = ?
10951095 WHERE issuerID = ?
0 commit comments