@@ -52,12 +52,12 @@ type groupState struct {
52
52
// When some group is complete cancels all requests that are not needed by any
53
53
// group.
54
54
type safeSubmissionState struct {
55
- mu sync.Mutex
56
- logToGroups map [string ]ctpolicy.GroupSet
57
- groupNeeds map [string ]int // number of logs that need to be submitted for each group.
58
- maxSubmissionsPerGroup int // maximum number of logs that can be submitted to a group.
55
+ mu sync.Mutex
56
+ logToGroups map [string ]ctpolicy.GroupSet
57
+ groupNeeds map [string ]int // number of logs that need to be submitted for each group.
58
+ minDistinctGroups int // number of groups that need a submission
59
59
60
- groups map [string ]int // number of logs submitted to each group..
60
+ groups map [string ]bool // groups that have a stored result
61
61
results map [string ]* submissionResult
62
62
cancels map [string ]context.CancelFunc
63
63
}
@@ -70,9 +70,9 @@ func newSafeSubmissionState(groups ctpolicy.LogPolicyData) *safeSubmissionState
70
70
s .groupNeeds [g .Name ] = g .MinInclusions
71
71
}
72
72
if baseGroup , ok := groups [ctpolicy .BaseName ]; ok {
73
- s .maxSubmissionsPerGroup = baseGroup .MaxSubmissionsPerOperator
73
+ s .minDistinctGroups = baseGroup .MinDistinctOperators
74
74
}
75
- s .groups = make (map [string ]int )
75
+ s .groups = make (map [string ]bool )
76
76
s .results = make (map [string ]* submissionResult )
77
77
s .cancels = make (map [string ]context.CancelFunc )
78
78
return & s
@@ -90,10 +90,6 @@ func (sub *safeSubmissionState) request(logURL string, cancel context.CancelFunc
90
90
sub .results [logURL ] = & submissionResult {}
91
91
isAwaited := false
92
92
for g := range sub .logToGroups [logURL ] {
93
- if g != ctpolicy .BaseName && sub .groups [g ] < sub .maxSubmissionsPerGroup {
94
- isAwaited = true
95
- break
96
- }
97
93
if sub .groupNeeds [g ] > 0 {
98
94
isAwaited = true
99
95
break
@@ -119,21 +115,21 @@ func (sub *safeSubmissionState) setResult(logURL string, sct *ct.SignedCertifica
119
115
}
120
116
// group name associated with logURL outside of BaseName.
121
117
// (this assumes the logURL is associated with only one group ignoring BaseName)
122
- var nonBaseGroupName string
123
118
// If at least one group needs that SCT, result is set. Otherwise dumped.
124
119
for groupName := range sub .logToGroups [logURL ] {
125
120
// Ignore the base group (All-logs) here to check separately.
126
121
if groupName == ctpolicy .BaseName {
127
122
continue
128
123
}
129
- nonBaseGroupName = groupName
130
- if sub .groups [groupName ] < sub . maxSubmissionsPerGroup {
124
+ // Set the result if the group does not have a submission.
125
+ if ! sub .groups [groupName ] {
131
126
sub .results [logURL ] = & submissionResult {sct : sct , err : err }
127
+ sub .groups [groupName ] = true
132
128
}
133
129
if sub .groupNeeds [groupName ] > 0 {
134
130
sub .results [logURL ] = & submissionResult {sct : sct , err : err }
131
+ sub .groups [groupName ] = true
135
132
}
136
- sub .groups [groupName ]++
137
133
sub .groupNeeds [groupName ]--
138
134
}
139
135
@@ -143,19 +139,12 @@ func (sub *safeSubmissionState) setResult(logURL string, sct *ct.SignedCertifica
143
139
// It is already processed in a non-base group, so we can reduce the groupNeeds for the base group as well.
144
140
sub .groupNeeds [ctpolicy .BaseName ]--
145
141
} else if sub .groupNeeds [ctpolicy .BaseName ] > 0 {
146
- minInclusionsForOtherGroup := 0
147
- for g , cnt := range sub .groupNeeds {
148
- if g != ctpolicy .BaseName && cnt > 0 {
149
- minInclusionsForOtherGroup += cnt
150
- }
151
- }
142
+ extraSubmissions := sub .minDistinctGroups - len (sub .groups )
152
143
// Set the result only if the base group still needs SCTs more than total counts
153
144
// of minimum inclusions for other groups.
154
- if sub .groupNeeds [ctpolicy .BaseName ] > minInclusionsForOtherGroup {
155
- if sub .groups [nonBaseGroupName ] < sub .maxSubmissionsPerGroup {
156
- sub .results [logURL ] = & submissionResult {sct : sct , err : err }
157
- sub .groupNeeds [ctpolicy .BaseName ]--
158
- }
145
+ if sub .groupNeeds [ctpolicy .BaseName ] > extraSubmissions {
146
+ sub .results [logURL ] = & submissionResult {sct : sct , err : err }
147
+ sub .groupNeeds [ctpolicy .BaseName ]--
159
148
}
160
149
}
161
150
}
@@ -165,10 +154,6 @@ func (sub *safeSubmissionState) setResult(logURL string, sct *ct.SignedCertifica
165
154
for logURL , groupSet := range sub .logToGroups {
166
155
isAwaited := false
167
156
for g := range groupSet {
168
- if g != ctpolicy .BaseName && sub .groups [g ] < sub .maxSubmissionsPerGroup {
169
- isAwaited = true
170
- break
171
- }
172
157
if sub .groupNeeds [g ] > 0 {
173
158
isAwaited = true
174
159
break
@@ -189,10 +174,8 @@ func (sub *safeSubmissionState) groupComplete(groupName string) bool {
189
174
if ! ok {
190
175
return true
191
176
}
192
- for _ , submission := range sub .groups {
193
- if submission < sub .maxSubmissionsPerGroup {
194
- return false
195
- }
177
+ if len (sub .groups ) < sub .minDistinctGroups {
178
+ return false
196
179
}
197
180
return needs <= 0
198
181
}
0 commit comments