@@ -235,7 +235,9 @@ def __contains__(self, item: object) -> bool:
235235
236236 return False
237237
238- def append (self , ballot : CiphertextAcceptedBallot ) -> bool :
238+ def append (
239+ self , ballot : CiphertextAcceptedBallot , scheduler : Optional [Scheduler ] = None
240+ ) -> bool :
239241 """
240242 Append a ballot to the tally and recalculate the tally.
241243 """
@@ -251,7 +253,7 @@ def append(self, ballot: CiphertextAcceptedBallot) -> bool:
251253 return False
252254
253255 if ballot .state == BallotBoxState .CAST :
254- return self ._add_cast (ballot )
256+ return self ._add_cast (ballot , scheduler )
255257
256258 if ballot .state == BallotBoxState .SPOILED :
257259 return self ._add_spoiled (ballot )
@@ -261,7 +263,11 @@ def append(self, ballot: CiphertextAcceptedBallot) -> bool:
261263
262264 SELECTION_ID = str
263265
264- def batch_append (self , ballots : Iterable [CiphertextAcceptedBallot ]) -> bool :
266+ def batch_append (
267+ self ,
268+ ballots : Iterable [CiphertextAcceptedBallot ],
269+ scheduler : Optional [Scheduler ] = None ,
270+ ) -> bool :
265271 """
266272 Append a collection of Ballots to the tally and recalculate
267273 """
@@ -289,7 +295,7 @@ def batch_append(self, ballots: Iterable[CiphertextAcceptedBallot]) -> bool:
289295 self ._add_spoiled (ballot )
290296
291297 # cache the cast ballot id's so they are not double counted
292- if self ._execute_accumulate (cast_ballot_selections ):
298+ if self ._execute_accumulate (cast_ballot_selections , scheduler ):
293299 for ballot in ballots :
294300 if ballot .state == BallotBoxState .CAST :
295301 self ._cast_ballot_ids .add (ballot .object_id )
@@ -312,7 +318,9 @@ def _accumulate(
312318 elgamal_add (* [ciphertext for ciphertext in ballot_selections .values ()]),
313319 )
314320
315- def _add_cast (self , ballot : CiphertextAcceptedBallot ) -> bool :
321+ def _add_cast (
322+ self , ballot : CiphertextAcceptedBallot , scheduler : Optional [Scheduler ] = None
323+ ) -> bool :
316324 """
317325 Add a cast ballot to the tally, synchronously
318326 """
@@ -328,7 +336,7 @@ def _add_cast(self, ballot: CiphertextAcceptedBallot) -> bool:
328336 return False
329337
330338 use_contest = self .cast [contest .object_id ]
331- if not use_contest .accumulate_contest (contest .ballot_selections ):
339+ if not use_contest .accumulate_contest (contest .ballot_selections , scheduler ):
332340 return False
333341
334342 self .cast [contest .object_id ] = use_contest
@@ -372,10 +380,12 @@ def _execute_accumulate(
372380 ciphertext_selections_by_selection_id : Dict [
373381 str , Dict [BALLOT_ID , ElGamalCiphertext ]
374382 ],
383+ scheduler : Optional [Scheduler ] = None ,
375384 ) -> bool :
376385
377386 result_set : List [Tuple [SELECTION_ID , ElGamalCiphertext ]]
378- scheduler = Scheduler ()
387+ if not scheduler :
388+ scheduler = Scheduler ()
379389 result_set = scheduler .schedule (
380390 self ._accumulate ,
381391 [
0 commit comments