Module elections

Source
Expand description

Defines two distinct pluggable election models for ranking and selecting candidates based on their stake, backing, or influence metrics.

Elections are abstracted into two main models:

§Flat Election (flat)

  • Aggregates all contributions (including the candidates’s own stake-if any) into a single scalar metric.
  • Candidates are compared using their flattened total weight.
  • Useful for scenarios where every unit of support counts equally and simple proportionality is desired.

§Fair Election (fair)

  • Each backer’s contribution is kept unaggregated (including the candidate’s own stake-if any as one of the backing), preserving individual influence granularity.
  • Useful when the goal is to prevent candidates from dominating through self-funding and emphasize external support.

§Purpose

Separating election models into flat and fair provides flexibility:

  • Flat for simple, proportional elections where total stake matters.
  • Fair for more security-conscious or governance-focused elections emphasizing community support.

Both models implement a pluggable algorithm interface, enabling runtime substitution, testing of different strategies, and easy extension with new election rules.

Re-exports§

pub use flat::*;
pub use fair::*;

Modules§

fair
Contains FairElection plugin models, which rank entities using a fair weight, where each entity’s weight is derived from a list of contributors and their individual contributions.
flat
Contains FlatElection plugin models, which rank entities using a single aggregated scalar (flat weight) computed from a list of entities and their corresponding weights.