Skip to content

Commit

Permalink
chore: change the logic so database read is outside of enforce
Browse files Browse the repository at this point in the history
  • Loading branch information
wooglie committed Apr 10, 2024
1 parent 250ad89 commit 0501591
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions proof-of-us-v1/proof-of-us.pact
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,13 @@

(defun enforce-guard-count:bool (guards:[guard] threshold:integer)
"Will succeed if at least the threshold of guards is successfully enforced."
(enforce (<= threshold
(length
(filter
(= true)
(map (try-enforce-guard) guards))))
"Guard threshold not met")
(let* (
(attemps:[bool] (map (try-enforce-guard) guards))
(filtered:[bool] (filter (= true) attemps))
(len:integer (length filtered))
)
(enforce (<= threshold len) "Guard threshold not met")
)
)

(defun try-enforce-guard (guard:guard)
Expand Down

0 comments on commit 0501591

Please sign in to comment.