v1 source pure
Package rulecalc holds the evaluation rule schema for a grant round and the deterministic computation of its outcome....
Package rulecalc holds the evaluation rule schema for a grant round and the deterministic computation of its outcome. It has no state and moves no coins.
3
4
func AppsDigest
AppsDigest is the commitment to an application list, published before the rule phase and checked at reveal: hex(sha256) of one "Title|PkgPath|Payout\n" line per app, in order, followed by salt. It panics if a field contains "|" or a newline, or the salt contains a newline, since the same digest could then open to a different list.
Off-chain equivalent:
Example
1printf 'Title|PkgPath|Payout\n...salt' | sha256sum
func Compute
Compute returns the winning app ID. paid == false means the grant is refunded: no apps, fewer sheets than the quorum, or a top-level tie under the Refund tie-break. Sheets must already pass ValidateSheet.
func Totals
Totals returns the per-app figure the rule's method ranks by: weighted score sums for WeightedSum, first-place counts for MajorityFirst. Sheets must already pass ValidateSheet.
func ValidateSheet
ValidateSheet checks that s scores every app on every criterion within 0-10.
6
type App
structApp is one grant application. Its ID is its index in the revealed list.
type Criterion
structCriterion is one named, weighted evaluation axis.
type Method
identMethod is how evaluator score sheets are aggregated into a winner.
type Rule
structRule is the procedure the evaluators agree on before applications are revealed. Rationale is shown to readers and never affects computation.
type Sheet
structSheet is one evaluator's scores: Scores[app][criterion], apps ordered by ID 0..n-1, criteria in the order of Rule.Criteria.
type TieBreak
identTieBreak decides a top-level tie.