Skip to content

Commit

Permalink
Merge pull request #264 from Consensys/263-support-parallel-trace-che…
Browse files Browse the repository at this point in the history
…cking

feat: Support Parallel Constraint Checking
  • Loading branch information
DavePearce authored Jul 26, 2024
2 parents 00ed0b9 + 1f1b905 commit 5876153
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/schema/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,30 @@ func ExpandTrace(schema Schema, trace tr.Trace) error {
//
//nolint:revive
func Accepts(schema Schema, trace tr.Trace) error {
var err error
// Determine how many constraints
n := schema.Constraints().Count()
// Construct a communication channel for errors.
c := make(chan error, 100)
// Check each constraint in turn
for i := schema.Constraints(); i.HasNext(); {
// Get ith constraint
ith := i.Next()
// Check it holds (or report an error)
if err := ith.Accepts(trace); err != nil {
return err
// Launch checker for constraint
go func() {
// Send outcome back
c <- ith.Accepts(trace)
}()
}
// Read responses back from each constraint.
for i := uint(0); i < n; i++ {
// Read from channel
if e := <-c; e != nil {
err = e
}
}
// Success
return nil
return err
}

// ColumnIndexOf returns the column index of the column with the given name, or
Expand Down

0 comments on commit 5876153

Please sign in to comment.