Commit 9a940c5a authored by Stephane Glondu's avatar Stephane Glondu

Run check_ballot in a preemptive thread

parent e5bc81f1
...@@ -105,7 +105,8 @@ module Make (E : ELECTION with type 'a m = 'a Lwt.t) : WEB_BALLOT_BOX = struct ...@@ -105,7 +105,8 @@ module Make (E : ELECTION with type 'a m = 'a Lwt.t) : WEB_BALLOT_BOX = struct
match old_cred, old_record with match old_cred, old_record with
| None, None -> | None, None ->
(* first vote *) (* first vote *)
if E.check_ballot ballot then ( let%lwt b = Lwt_preemptive.detach E.check_ballot ballot in
if b then (
let hash = sha256_b64 rawballot in let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >> Ocsipersist.add cred_table credential (Some hash) >>
Ocsipersist.add ballots_table hash rawballot >> Ocsipersist.add ballots_table hash rawballot >>
...@@ -118,7 +119,8 @@ module Make (E : ELECTION with type 'a m = 'a Lwt.t) : WEB_BALLOT_BOX = struct ...@@ -118,7 +119,8 @@ module Make (E : ELECTION with type 'a m = 'a Lwt.t) : WEB_BALLOT_BOX = struct
| Some h, Some (_, old_credential) -> | Some h, Some (_, old_credential) ->
(* revote *) (* revote *)
if credential = old_credential then ( if credential = old_credential then (
if E.check_ballot ballot then ( let%lwt b = Lwt_preemptive.detach E.check_ballot ballot in
if b then (
Ocsipersist.remove ballots_table h >> Ocsipersist.remove ballots_table h >>
let hash = sha256_b64 rawballot in let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >> Ocsipersist.add cred_table credential (Some hash) >>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment